Esempio n. 1
0
        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());
            }
        }
Esempio n. 2
0
        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));
        }