public IActionResult SaveMpp(List <Dcs> DcsList) { Unions UnionsModel = GetLastRecord <Unions>("tbl_unions"); MccPlant MccPlantModel = GetLastRecord <MccPlant>("tbl_mcc_plant"); foreach (Dcs DcsModel in DcsList) { Data = new List <ModelParameter>(); if (DcsModel.dcs_code != "") { Dcs NewModel = NewRepo.FindByKey <Dcs>(DcsModel.dcs_code); if (NewModel == null) { if (UnionsModel.has_mcc == true) { DcsModel.mcc_plant_code = MccPlantModel.mcc_plant_code; } else { DcsModel.mcc_plant_code = DcsModel.bmc_code; } DcsModel.ref_code = DcsModel.dcs_code.PadLeft(15, '0'); DcsModel.originating_org_code = DcsModel.union_code = MccPlantModel.union_code; DcsModel.plant_code = MccPlantModel.plant_code; DcsModel.x_col1 = SetDcsXcol(DcsModel.allow_multiple_milktype); Data.Add(new ModelParameter { SaveModel = DcsModel, ValidateModel = new DcsValidator() }); } else { NewModel.dcs_name = DcsModel.dcs_name; NewModel.bmc_code = DcsModel.bmc_code; NewModel.route_code = DcsModel.route_code; NewModel.is_active = DcsModel.is_active; NewModel.contact_person = DcsModel.contact_person; NewModel.mobile_no = DcsModel.mobile_no; NewModel.allow_multiple_milktype = DcsModel.allow_multiple_milktype; NewModel.x_col1 = SetDcsXcol(DcsModel.allow_multiple_milktype); NewModel.model_operation = "update"; Data.Add(new ModelParameter { SaveModel = NewModel, ValidateModel = new DcsValidator() }); } SaveData(DcsModel.dcs_code); } else { _response.Add(new CustomResponse { status = "300", msg = "error:dcs_code" }); } } return(new CustomResult("success", _response)); }
public IActionResult SaveRoute(List <Route> RouteList) { Unions UnionsModel = GetLastRecord <Unions>("tbl_unions"); foreach (Route RouteModel in RouteList) { Data = new List <ModelParameter>(); if (RouteModel.route_code != "") { Route NewModel = NewRepo.FindByKey <Route>(RouteModel.route_code); if (RouteModel.route_type == null || RouteModel.route_type == "") { RouteModel.route_type = "Can"; } if (NewModel == null) { RouteModel.vehicle_type_code = (RouteModel.route_type == "Can") ? 1 : 2; RouteModel.to_dest = RouteModel.bmc_code; RouteModel.to_type = "bmc"; RouteModel.ref_code = RouteModel.route_code; RouteModel.union_code = RouteModel.originating_org_code = UnionsModel.union_code; Data.Add(new ModelParameter { SaveModel = RouteModel, ValidateModel = new RouteValidator() }); } else { NewModel.vehicle_type_code = (RouteModel.route_type == "Can") ? 1 : 2; NewModel.to_dest = RouteModel.bmc_code; NewModel.bmc_code = RouteModel.bmc_code; NewModel.route_name = RouteModel.route_name; NewModel.is_active = RouteModel.is_active; NewModel.route_supervisor_name = RouteModel.route_supervisor_name; NewModel.contact_no = RouteModel.contact_no; NewModel.model_operation = "update"; Data.Add(new ModelParameter { SaveModel = NewModel, ValidateModel = new RouteValidator() }); } SaveData(RouteModel.route_code); } else { _response.Add(new CustomResponse { status = "300", msg = "error:route_code" }); } } return(new CustomResult("success", _response)); }
private void OrgDetail() { Hierarchy = new Dictionary <string, List <string> >(); List <Dcs> OrgData = NewRepo.FindAll <Dcs>(new QueryParam { Fields = "union_code,plant_code,mcc_plant_code,bmc_code,dcs_code", Where = new List <ConditionParameter> { Condition("bmc_code", _request.organizationCode) } }).ToList(); if (OrgData == null) { Bmc BmcData = NewRepo.FindByKey <Bmc>(_request.organizationCode); Hierarchy.Add("union_code", new List <string> { BmcData.union_code }); Hierarchy.Add("plant_code", new List <string> { BmcData.plant_code }); Hierarchy.Add("mcc_plant_code", new List <string> { BmcData.mcc_plant_code }); Hierarchy.Add("bmc_code", new List <string> { _request.organizationCode }); Hierarchy.Add("dcs_code", new List <string> { "" }); } else { Hierarchy.Add("union_code", new List <string> { OrgData.Select(x => x.union_code).FirstOrDefault() }); Hierarchy.Add("plant_code", new List <string> { OrgData.Select(x => x.plant_code).FirstOrDefault() }); Hierarchy.Add("mcc_plant_code", new List <string> { OrgData.Select(x => x.mcc_plant_code).FirstOrDefault() }); Hierarchy.Add("bmc_code", new List <string> { _request.organizationCode }); Hierarchy.Add("dcs_code", OrgData.Select(x => x.dcs_code).ToList()); } }
public IActionResult SaveBmcAck(List <CustomResponse> CollectionCodeList) { foreach (CustomResponse code in CollectionCodeList) { BmcCollection collection = NewRepo.FindByKey <BmcCollection>(code.key_code); if (collection != null) { collection.data_post_status = 1; collection.model_operation = "update"; List <ModelParameter> Data = new List <ModelParameter>() { new ModelParameter { SaveModel = collection, ValidateModel = null } }; SingleRecordTransaction(Data, 3); } } return(new CustomResult("success", new CustomResponse { status = "200", msg = "success" })); }
public IActionResult Registration() { Bmc BmcModel = NewRepo.FindByKey <Bmc>(_request.organizationCode); dynamic data = new ExpandoObject(); if (BmcModel != null) { if (_request.content.mobileNo != null && _request.content.mobileNo.Trim() == BmcModel.contact_no.Trim()) { _data = new List <ModelParameter>(); AndroidInstallationDetails DetailModel; AndroidInstallation InstalationModel = NewRepo.FindByColumn <AndroidInstallation>(new List <ConditionParameter> { Condition("organization_code", BmcModel.bmc_code), Condition("organization_type", "BMC"), }); if (InstalationModel == null) { InstalationModel = new AndroidInstallation { android_installation_id = DbHelper.UniqueKey(), organization_code = BmcModel.bmc_code, organization_type = "BMC", }; DetailModel = SetDetail(InstalationModel.android_installation_id); _data.Add(new ModelParameter { ValidateModel = null, SaveModel = InstalationModel }); } else { DetailModel = NewRepo.FindByColumn <AndroidInstallationDetails>(new List <ConditionParameter> { Condition("android_installation_id", InstalationModel.android_installation_id), Condition("device_id", _request.deviceId), Condition("mobile_no", BmcModel.contact_no.Trim()), Condition("is_active", 1) }); if (DetailModel == null) { DetailModel = SetDetail(InstalationModel.android_installation_id); } else { DetailModel.model_operation = "update"; } } DetailModel.hash_key = DbHelper.UniqueKey(20); DetailModel.otp_code = 1234; DetailModel.is_active = false; DetailModel.is_expired = false; _data.Add(new ModelParameter { ValidateModel = null, SaveModel = DetailModel }); CustomResult result = AUDOperation(_data); if (result._result.message.ToLower() == "success") { data.token = DetailModel.hash_key; return(new CustomResult2(data)); } return(new CustomResult2(data, "Data Not Available")); } else { return(new CustomResult2(data, "Data Not Available")); } } else { return(new CustomResult2(data, "Data Not Available")); } }
public IActionResult SaveBmc(List <Bmc> BmcList) { Unions UnionsModel = GetLastRecord <Unions>("tbl_unions"); Plant PlantModel = GetLastRecord <Plant>("tbl_plant"); MccPlant MccModel = GetLastRecord <MccPlant>("tbl_mcc_plant"); foreach (Bmc BmcModel in BmcList) { Data = new List <ModelParameter>(); if (BmcModel.bmc_code != "") { Bmc NewModel = NewRepo.FindByKey <Bmc>(BmcModel.bmc_code); if (NewModel == null) { BmcModel.ref_code = BmcModel.bmc_code; BmcModel.union_code = BmcModel.originating_org_code = UnionsModel.union_code; BmcModel.plant_code = PlantModel.plant_code; if (UnionsModel.has_bmc == true && UnionsModel.has_mcc == false) { BmcModel.mcc_plant_code = BmcModel.bmc_code; MccPlant MccPlantModel = new MccPlant { mcc_plant_code = BmcModel.bmc_code, plant_code = PlantModel.plant_code, name = BmcModel.bmc_name, ref_code = BmcModel.ref_code, contact_person = BmcModel.bmc_incharge_name, mobile_no = BmcModel.contact_no }; MccPlantModel.union_code = MccPlantModel.originating_org_code = BmcModel.union_code; Data.Add(new ModelParameter { SaveModel = MccPlantModel, ValidateModel = new MccPlantValidator() }); } else { BmcModel.mcc_plant_code = MccModel.mcc_plant_code; } Data.Add(new ModelParameter { SaveModel = BmcModel, ValidateModel = new BmcValidator() }); } else { if (UnionsModel.has_bmc == true && UnionsModel.has_mcc == false) { MccPlant MccPlantModel = NewRepo.FindByKey <MccPlant>(BmcModel.bmc_code); MccPlantModel.name = BmcModel.bmc_name; MccPlantModel.contact_person = BmcModel.bmc_incharge_name; MccPlantModel.mobile_no = BmcModel.contact_no; MccPlantModel.model_operation = "update"; Data.Add(new ModelParameter { SaveModel = MccPlantModel, ValidateModel = new MccPlantValidator() }); } NewModel.bmc_name = BmcModel.bmc_name; NewModel.is_active = BmcModel.is_active; NewModel.bmc_incharge_name = BmcModel.bmc_incharge_name; NewModel.contact_no = BmcModel.contact_no; NewModel.model_operation = "update"; Data.Add(new ModelParameter { SaveModel = NewModel, ValidateModel = new BmcValidator() }); } SaveData(BmcModel.bmc_code); } else { _response.Add(new CustomResponse { status = "300", msg = "error:bmc_code" }); } } return(new CustomResult("success", _response)); }