Ejemplo n.º 1
0
        public IActionResult PurchaseRateApplicability(List <PurchaseRateApplicability> PurchaseRateApplicabilityList)
        {
            Unions     UnionsModel = GetLastRecord <Unions>("tbl_unions");
            QueryParam Query       = new QueryParam
            {
                Fields = "*"
            };
            IEnumerable <Shift> shiftList = NewRepo.FindAll <Shift>(Query);
            int code = NewRepo.Find <int>(new QueryParam {
                DirectQuery = "select IFNULL(max(rate_app_code),0) from tbl_purchase_rate_applicability"
            });

            foreach (PurchaseRateApplicability PurchaseRateApplicabilityModel in PurchaseRateApplicabilityList)
            {
                Data = new List <ModelParameter>();
                if (PurchaseRateApplicabilityModel.module_name.ToLower() == "dcs")
                {
                    if (PurchaseRateApplicabilityModel.rate_for == "farmer_collection")
                    {
                        PurchaseRateApplicabilityModel.rate_app_code        = (code + 1).ToString();
                        PurchaseRateApplicabilityModel.ref_code             = PurchaseRateApplicabilityModel.applicability_unique_code;
                        PurchaseRateApplicabilityModel.originating_org_code = PurchaseRateApplicabilityModel.union_code = UnionsModel.union_code;
                        PurchaseRateApplicabilityModel.dcs_code             = PurchaseRateApplicabilityModel.module_code;
                        PurchaseRateApplicabilityModel.shift_code           = shiftList.Where(x => x.short_name.ToLower() == PurchaseRateApplicabilityModel.shift.ToLower()).Select(x => x.id).FirstOrDefault();
                        string time = PurchaseRateApplicabilityModel.wef_date.ToString("yyyy-MM-dd") + " " + shiftList.Where(x => x.short_name.ToLower() == PurchaseRateApplicabilityModel.shift.ToLower()).Select(x => x.shift_time.ToString(@"hh\:mm\:ss")).FirstOrDefault();
                        PurchaseRateApplicabilityModel.wef_date = DateHelper.ParseDate(time);
                        Data.Add(new ModelParameter {
                            SaveModel = PurchaseRateApplicabilityModel, ValidateModel = new PurchaseRateApplicabilityValidator()
                        });
                        SaveData(PurchaseRateApplicabilityModel.applicability_unique_code);
                    }
                }
            }
            return(new CustomResult("success", _response));
        }
Ejemplo n.º 2
0
        private T GetLastRecord <T>(string table) where T : BaseModel
        {
            QueryParam Query = new QueryParam
            {
                Fields  = "*",
                Table   = table,
                OrderBy = "created_at desc"
            };

            return(NewRepo.Find <T>(Query));
        }
        public IActionResult SaveAck(Acknowledgemen _requst)
        {
            string  message = "Sentbox Not Updated.";
            dynamic data    = new ExpandoObject();
            string  status  = NewRepo.Find <string>(new QueryParam
            {
                Fields = "tbl_android_installation.android_installation_id",
                Table  = "tbl_android_installation_details",
                Join   = new List <JoinParameter>
                {
                    new JoinParameter {
                        table = "tbl_android_installation", condition = "tbl_android_installation.android_installation_id=tbl_android_installation_details.android_installation_id"
                    },
                },
                Where = new List <ConditionParameter> {
                    Condition("hash_key", _requst.token),
                    Condition("tbl_android_installation_details.is_active", 1),
                    Condition("is_expired", 0),
                    Condition("device_id", _requst.deviceId),
                    Condition("tbl_android_installation.organization_code", _requst.organizationCode),
                    Condition("organization_type", _requst.organizationType)
                }
            });

            if (status.Trim() != "")
            {
                bool flag = NewRepo.Delete(new List <QueryParam> {
                    new QueryParam
                    {
                        Table = "tbl_sentbox",
                        Where = new List <ConditionParameter>
                        {
                            Condition("uuid", _requst.content.uuid.ToArray())
                        }
                    },
                    new QueryParam
                    {
                        Table = "tbl_sentbox_clone",
                        Where = new List <ConditionParameter>
                        {
                            Condition("uuid", _requst.content.uuid.ToArray())
                        }
                    }
                });
                if (flag)
                {
                    message = "Sentbox Updated Successfully.";
                }
            }
            data.message = message;
            return(new CustomResult2(data));
        }
Ejemplo n.º 4
0
        public IActionResult UpdateDeviceToken(Users userModel)
        {
            Data = new List <ModelParameter>();
            QueryParam Query = new QueryParam
            {
                Where = new List <ConditionParameter>
                {
                    Condition("user_code", userModel.user_code),
                    Condition("device_id", userModel.device_id),
                },
            };
            Users UserModel = NewRepo.Find <Users>(Query);

            if (UserModel == null)
            {
                return(new CustomResult("error", "no_device_found"));
            }
            UserModel.device_token = userModel.device_token;
            Data.Add(new ModelParameter {
                ValidateModel = new UsersValidator(), SaveModel = UserModel
            });
            return(UpdateData(Data));
        }
Ejemplo n.º 5
0
        public IActionResult Verification()
        {
            dynamic data = new ExpandoObject();
            AndroidInstallationDetails DetailModel = NewRepo.FindByColumn <AndroidInstallationDetails>(new List <ConditionParameter> {
                Condition("hash_key", _request.token),
                Condition("otp_code", _request.content.otpCode),
                Condition("imei_no", _request.imei),
            });

            if (DetailModel == null)
            {
                return(new CustomResult2(data, "OTP Not Verified."));
            }
            else
            {
                _data  = new List <ModelParameter>();
                _query = new QueryParam
                {
                    Where = new List <ConditionParameter>
                    {
                        Condition("android_installation_id", DetailModel.android_installation_id),
                        Condition("android_installation_details_id", DetailModel.android_installation_details_id, "!=")
                    }
                };
                List <AndroidInstallationDetails> DetailList = NewRepo.FindAll <AndroidInstallationDetails>(_query).ToList();
                foreach (AndroidInstallationDetails UdateDetailModel in DetailList.NotEmpty())
                {
                    UdateDetailModel.sync_active     = false;
                    UdateDetailModel.model_operation = "update";
                    _data.Add(new ModelParameter {
                        ValidateModel = null, SaveModel = UdateDetailModel
                    });
                }
                DetailModel.is_active       = true;
                DetailModel.sync_key        = NumericHelper.RandomNumber().ToString();
                DetailModel.sync_active     = true;
                DetailModel.model_operation = "update";
                _data.Add(new ModelParameter {
                    ValidateModel = null, SaveModel = DetailModel
                });
                CustomResult result = AUDOperation(_data);
                if (result._result.message.ToLower() == "success")
                {
                    _query = new QueryParam
                    {
                        Fields = "tbl_mcc_plant.mcc_plant_code,tbl_mcc_plant.name",
                        Join   = new List <JoinParameter>
                        {
                            new JoinParameter {
                                table = "tbl_bmc", condition = "tbl_bmc.mcc_plant_code=tbl_mcc_plant.mcc_plant_code"
                            }
                        },
                        Where = new List <ConditionParameter>
                        {
                            Condition("bmc_code", _request.organizationCode)
                        }
                    };
                    MccPlant MccModel = NewRepo.Find <MccPlant>(_query);
                    if (MccModel == null)
                    {
                        return(new CustomResult2(data, "OTP Not Verified."));
                    }
                    data.message    = "OTP Verified";
                    data.syncKey    = DetailModel.sync_key;
                    data.parentType = "MCC";
                    data.parentCode = MccModel.mcc_plant_code;
                    data.parentName = MccModel.name;
                    return(new CustomResult2(data));
                }
                return(new CustomResult2(data, "OTP Not Verified."));
            }
        }
Ejemplo n.º 6
0
        //private string CheckCustomerCode(string customer_type)
        //{
        //    QueryParam Query = new QueryParam
        //    {
        //        Fields = "*",
        //        Table = "tbl_customer_type",
        //        Where = new List<ConditionParameter>
        //            {
        //                Condition("customer_type",customer_type)
        //            }
        //    };
        //    CustomerType CustomerTypeModel = NewRepo.Find<CustomerType>(Query);


        //    if (CustomerTypeModel.customer_type== "VENDOR") { }



        //}
        public IActionResult Upload(IFormFile File, int rate_type)
        {
            Data = new List <ModelParameter>();
            if (Path.GetExtension(File.FileName).ToLower() != ".csv")
            {
                return(new CustomResult("success", new CustomResponse {
                    key_code = "0", status = "300", msg = "error:Only Csv File Allowed"
                }));
            }
            string[] param = File.FileName.Split('_');
            if (param.Count() != 2)
            {
                return(new CustomResult("success", new CustomResponse {
                    key_code = "0", status = "300", msg = "error:Wrong FileName Format"
                }));
            }
            string DirectoryPath = FileHelper.FileServerPath();

            FileHelper.CreateDirectory(FileHelper.FileServerPath());
            ImportFile ImportFileModel = new ImportFile
            {
                file_name     = File.FileName,
                process_name  = "purchase_rate",
                new_file_path = FileHelper.NewFileName(DirectoryPath, "purchase_rate", "csv")
            };

            Data.Add(new ModelParameter {
                ValidateModel = new ImportFileValidator(), SaveModel = ImportFileModel
            });
            using (var fileStream = new FileStream(ImportFileModel.new_file_path, FileMode.Create))
            {
                File.CopyTo(fileStream);
                SaveData(Data);
            }
            string rate = NewRepo.Find <string>(new QueryParam {
                Fields = "purchase_rate_code",
                Table  = "tbl_purchase_rate",
                Where  = new List <ConditionParameter> {
                    Condition("purchase_rate_code", param[0].Trim())
                }
            });

            if (rate == param[0].Trim())
            {
                return(new CustomResult("success", new CustomResponse {
                    key_code = param[0], status = "300", msg = "error:Rate already Exist"
                }));
            }
            string tablename   = NumericHelper.RandomNumber().ToString() + "tmp";
            string DirectQuery = $"create table {tablename}(id int not null AUTO_INCREMENT PRIMARY KEY,fat decimal(18,2),snf decimal(18,2),milk_type varchar(5),rtpl decimal(18,2),class varchar(5) null default '0',milk_type_code int null); LOAD DATA LOCAL INFILE  '{ImportFileModel.new_file_path.Replace('\\', '/')}' INTO TABLE {tablename}  FIELDS TERMINATED BY ';'  IGNORE 1 ROWS (fat,snf,milk_type,rtpl); ";

            if (rate_type != 0)
            {
                DirectQuery = $"create table {tablename}(id int not null AUTO_INCREMENT PRIMARY KEY,fat decimal(18,2),snf decimal(18,2),milk_type varchar(5),rtpl decimal(18,2),class varchar(5) null default '0',milk_type_code int null); LOAD DATA LOCAL INFILE  '{ImportFileModel.new_file_path.Replace('\\', '/')}' INTO TABLE {tablename} FIELDS TERMINATED BY ';'  IGNORE 1 ROWS (fat,snf,milk_type,rtpl,class); ";
            }
            NewRepo.Add(new QueryParam
            {
                DirectQuery = DirectQuery
            });
            string value = NewRepo.Find <string>(new QueryParam {
                Sp    = "import_rate",
                Where = new List <ConditionParameter>
                {
                    Condition("p_rate_code", param[0].Trim()),
                    Condition("p_rate_date", $"{param[1].Substring(4,4)}-{param[1].Substring(2,2)}-{param[1].Substring(0,2)}"),
                    Condition("p_table_name", tablename),
                    Condition("p_usercode", UserData.user_code),
                }
            });

            if (value == "1")
            {
                return(new CustomResult("success", new CustomResponse {
                    key_code = param[0], status = "200", msg = "success"
                }));
            }
            else
            {
                return(new CustomResult("success", new CustomResponse {
                    key_code = param[0], status = "300", msg = "error"
                }));
            }
        }
Ejemplo n.º 7
0
        public IActionResult SaveCustomer(List <CustomerMaster> CustomerMasterList)
        {
            Unions     UnionsModel = GetLastRecord <Unions>("tbl_unions");
            QueryParam Query       = new QueryParam
            {
                Fields = "*",
                Table  = "tbl_customer_type"
            };
            List <CustomerType> CustomerTypeList = NewRepo.FindAll <CustomerType>(Query).ToList();

            foreach (CustomerMaster CustomerMasterModel in CustomerMasterList)
            {
                Data = new List <ModelParameter>();

                if (CustomerMasterModel.customer_unique_code.Trim() != "")
                {
                    string prefix = CustomerTypeList.Where(x => x.customer_type == CustomerMasterModel.customer_type).Select(x => x.code_prefix).FirstOrDefault();
                    if (CheckPrefix(prefix, CustomerMasterModel.customer_code))
                    {
                        CustomerMaster NewModel = NewRepo.Find <CustomerMaster>(new QueryParam {
                            Where = new List <ConditionParameter> {
                                Condition("ref_code", CustomerMasterModel.customer_unique_code)
                            }
                        });
                        if (NewModel == null)
                        {
                            CustomerMasterModel.ref_code             = CustomerMasterModel.customer_unique_code;
                            CustomerMasterModel.x_col1               = SetDcsXcol(CustomerMasterModel.allow_multiple_milktype);
                            CustomerMasterModel.originating_org_code = CustomerMasterModel.union_code = UnionsModel.union_code;
                            Data.Add(new ModelParameter {
                                SaveModel = CustomerMasterModel, ValidateModel = new CustomerMasterValidator()
                            });
                        }
                        else
                        {
                            NewModel.customer_unique_code = CustomerMasterModel.customer_unique_code;
                            NewModel.bmc_code             = CustomerMasterModel.bmc_code;
                            NewModel.x_col1          = SetDcsXcol(CustomerMasterModel.allow_multiple_milktype);
                            NewModel.route_code      = CustomerMasterModel.route_code;
                            NewModel.customer_name   = CustomerMasterModel.customer_name;
                            NewModel.is_active       = CustomerMasterModel.is_active;
                            NewModel.mobile_no       = CustomerMasterModel.mobile_no;
                            NewModel.customer_type   = CustomerMasterModel.customer_type;
                            NewModel.model_operation = "update";
                            Data.Add(new ModelParameter {
                                SaveModel = NewModel, ValidateModel = new CustomerMasterValidator()
                            });
                        }
                        SaveData(CustomerMasterModel.customer_unique_code);
                    }
                    else
                    {
                        _response.Add(new CustomResponse {
                            status = "300", msg = "error:customer_code:Invalid Code"
                        });
                    }
                }
                else
                {
                    _response.Add(new CustomResponse {
                        status = "300", msg = "error:customer_unique_code:Require"
                    });
                }
            }
            return(new CustomResult("success", _response));
        }
Ejemplo n.º 8
0
        public IActionResult SaveMember(List <Member> MemberList)
        {
            Unions UnionsModel = GetLastRecord <Unions>("tbl_unions");

            foreach (Member MemberModel in MemberList)
            {
                Data = new List <ModelParameter>();
                if (MemberModel.member_unique_code.Trim() != "")
                {
                    if (MemberModel.member_code.Length > 4)
                    {
                        return(new CustomResult("success", new CustomResponse {
                            status = "300", msg = "error:member_code:Max Length Should be 4"
                        }));
                    }
                    WelcomeParamStationResult _welcome = NewRepo.Find <WelcomeParamStationResult>(new QueryParam
                    {
                        Fields = "welcome_param_station_result.id,welcome_param_id,station_code,param_value",
                        Join   = new List <JoinParameter>
                        {
                            new JoinParameter {
                                table = "welcome_params", condition = "welcome_params.id=welcome_param_id and param_name=\"NameFlag\""
                            },
                            new JoinParameter {
                                table = "tbl_dcs", condition = "tbl_dcs.ref_code=welcome_param_station_result.station_code"
                            }
                        },
                        Where = new List <ConditionParameter>
                        {
                            Condition("tbl_dcs.dcs_code", MemberModel.dcs_code)
                        }
                    });
                    if (_welcome != null)
                    {
                        _welcome.model_operation = "update";
                        _welcome.param_value     = "Y";
                        Data.Add(new ModelParameter {
                            SaveModel = _welcome, ValidateModel = null
                        });
                    }
                    Member NewModel = NewRepo.Find <Member>(new QueryParam {
                        Where = new List <ConditionParameter> {
                            Condition("ref_code", MemberModel.member_unique_code)
                        }
                    });
                    if (NewModel == null)
                    {
                        MemberModel.ex_member_code       = MemberModel.member_code;
                        MemberModel.member_code          = MemberModel.dcs_code + MemberModel.member_code.PadLeft(4, '0');
                        MemberModel.originating_org_code = UnionsModel.union_code;
                        MemberModel.ref_code             = MemberModel.member_unique_code;
                        Data.Add(new ModelParameter {
                            SaveModel = MemberModel, ValidateModel = new MemberValidator()
                        });
                    }
                    else
                    {
                        NewModel.member_unique_code = MemberModel.member_unique_code;
                        NewModel.dcs_code           = MemberModel.dcs_code;
                        NewModel.member_name        = MemberModel.member_name;
                        NewModel.is_active          = MemberModel.is_active;
                        NewModel.mobile_no          = MemberModel.mobile_no;
                        NewModel.model_operation    = "update";
                        Data.Add(new ModelParameter {
                            SaveModel = NewModel, ValidateModel = new MemberValidator()
                        });
                    }
                    SaveData(MemberModel.member_unique_code);
                }
                else
                {
                    _response.Add(new CustomResponse {
                        status = "300", msg = "error:member_unique_code:require"
                    });
                }
            }
            return(new CustomResult("success", _response));
        }