back-end/app/controllers/complaint_controller.rb
# assign new complaint to respective district office
assign new complaint to respective district office
assign new complaint to respective district office
def register_new_complaint(complaint_id, state, district, subject_of_complaint, sub_category)
    district_office = DistrictOffice.where(state: state, district: district).first
    if district_office
      district_admin = AdminUser.where(designation: "district officer",
                                       municipal_id: district_office.id).first
      if district_admin
        complaint_update = ComplaintUpdate.new(complaint_id: complaint_id,
                                               assigned_to: "District Municipal Officer: " + district_admin.name,
                                               notes: "Auto Assignment by System to concerned district office")
        complaint_status = ComplaintStatus.new(complaint_id: complaint_id,
                                               admin_user_id: district_admin.id,
                                               district_office_id: district_office.id,
                                               department: subject_of_complaint,
                                               status: "new")
        if complaint_update.save && complaint_status.save
          return "Complaint forwarded to concerned officer"
        else
          return "Update to complaint failed"
        end
      else
        return "Data for concerned Municipal officer doesn't exist"
      end
    else
      return "Data for concerned Municipal office doesn't exist"
    end
  end
def register_new_complaint ( complaint_id , state , district , subject_of_complaint , sub_category ) district_office = DistrictOffice . where ( state : state , district : district ) . first if district_office district_admin = AdminUser . where ( designation : "district officer" , municipal_id : district_office . id ) . first if district_admin complaint_update = ComplaintUpdate . new ( complaint_id : complaint_id , assigned_to : "District Municipal Officer: " + district_admin . name , notes : "Auto Assignment by System to concerned district office" ) complaint_status = ComplaintStatus . new ( complaint_id : complaint_id , admin_user_id : district_admin . id , district_office_id : district_office . id , department : subject_of_complaint , status : "new" ) if complaint_update . save && complaint_status . save return "Complaint forwarded to concerned officer" else return "Update to complaint failed" end else return "Data for concerned Municipal officer doesn't exist" end else return "Data for concerned Municipal office doesn't exist" end end
assign new complaint to respective district office
assign new complaint to respective district office
complaint_id
<not_specific>
state
<not_specific>
district
<not_specific>
subject_of_complaint
<not_specific>
sub_category
<not_specific>