Ejemplo n.º 1
0
        public async Task PutEntity(POS_Master entity)
        {
            entity.Modified_Date = DateTime.Now;
            string userid = HttpContext.User.Claims.Where(item => item.Type == System.Security.Claims.ClaimTypes.NameIdentifier).FirstOrDefault().Value;
            Users  _users = await userRepository.GetUserAndRoles(int.Parse(userid));

            entity.Modified_User = _users.name;
            await Repository.PutEntity(entity);
        }
Ejemplo n.º 2
0
        public async Task <object> InsertPos_MasterInfo(POS_Master entity)
        {
            ResultModel result = new ResultModel();

            result.IsSuccess = false;

            try
            {
                string userid = HttpContext.User.Claims.Where(item => item.Type == System.Security.Claims.ClaimTypes.NameIdentifier).FirstOrDefault().Value;
                Users  _users = await userRepository.GetUserAndRoles(int.Parse(userid));

                entity.Modified_User = _users.name;
                entity.Created_Date  = DateTime.Now;
                #region 生成Dummy Code  即POS_CODE
                //Dummy Code的生成规则:Dummy Year(2 digit sequential number)&Quarter+"-"+Customer Short Name+Branch+"-"+Channel short Name+2 digit sequential number
                string paraname = entity.TM_YEAR.Substring(2, 2) + entity.TM_SEASON + "-" + entity.CUSTOMER_GROUP + entity.BRANCH_EN + "-" + entity.POS_CHANNEL.Substring(0, 1);

                var maxindex = Repository.GetMaxPOSCode(paraname);
                if (!string.IsNullOrEmpty(maxindex.ToString()))
                {
                    int index = int.Parse(maxindex.ToString());
                    if (index > 0)
                    {
                        index++;
                        entity.POS_CODE = paraname + (index < 10 ? "0" + index : index + "");
                    }
                    else
                    {
                        entity.POS_CODE = paraname + "01";
                    }
                }
                else
                {
                    entity.POS_CODE = paraname + "01";
                }

                #endregion
                #region 验证 ship to Code
                if (!string.IsNullOrEmpty(entity.STC_CORE))
                {
                    entity.STC_CORE = entity.STC_CORE.ToUpper();
                    if (entity.STC_CORE != "TBD")
                    {
                        string Productchannel = Repository.GetProductchannel(entity.STC_CORE);
                        entity.Product_Channel = Productchannel;
                        if (string.IsNullOrEmpty(Productchannel) || Productchannel.ToString().ToLower() != "core")
                        {
                            result.Message = "Ship to Code(Core) is Error!";
                            return(Ok(result));
                        }
                        int reuslt = Repository.ExistshipCode(entity.STC_CORE, 1);
                        if (reuslt > 0)
                        {
                            //ship to code 是否正确
                            result.Message = "Ship to Code(Core) is exist!";
                            return(Ok(result));
                        }
                    }
                }

                if (!string.IsNullOrEmpty(entity.STC_OCS))
                {
                    entity.STC_OCS = entity.STC_OCS.ToUpper();
                    if (entity.STC_OCS != "TBD")
                    {
                        string Productchannel = Repository.GetProductchannel(entity.STC_OCS);
                        entity.Product_Channel = Productchannel;
                        if (string.IsNullOrEmpty(Productchannel) || Productchannel.ToLower() != "originals")
                        {
                            result.Message = "Ship to Code(Originals) is Error!";
                            return(Ok(result));
                        }
                        int reuslt = Repository.ExistshipCode(entity.STC_OCS, 2);
                        if (reuslt > 0)
                        {
                            //ship to code 是否正确
                            result.Message = "Ship to Code(Originals) is exist!";
                            return(Ok(result));
                        }
                    }
                }

                if (!string.IsNullOrEmpty(entity.STC_NEO))
                {
                    entity.STC_NEO = entity.STC_NEO.ToUpper();
                    if (entity.STC_NEO != "TBD")
                    {
                        string Productchannel = Repository.GetProductchannel(entity.STC_NEO);
                        entity.Product_Channel = Productchannel;
                        if (string.IsNullOrEmpty(Productchannel) || Productchannel.ToLower() != "neo")
                        {
                            result.Message = "Ship to Code(Neo) is Error!";
                            return(Ok(result));
                        }
                        int reuslt = Repository.ExistshipCode(entity.STC_NEO, 3);
                        if (reuslt > 0)
                        {
                            //ship to code 是否正确
                            result.Message = "Ship to Code(Neo) is exist!";
                            return(Ok(result));
                        }
                    }
                }

                if (!string.IsNullOrEmpty(entity.STC_KIDS))
                {
                    entity.STC_KIDS = entity.STC_KIDS.ToUpper();
                    if (entity.STC_KIDS != "TBD")
                    {
                        string Productchannel = Repository.GetProductchannel(entity.STC_KIDS);
                        entity.Product_Channel = Productchannel;
                        if (string.IsNullOrEmpty(Productchannel) || Productchannel.ToLower() != "kids")
                        {
                            result.Message = "Ship to Code(Kids) is Error!";
                            return(Ok(result));
                        }
                        int reuslt = Repository.ExistshipCode(entity.STC_KIDS, 4);
                        if (reuslt > 0)
                        {
                            //ship to code 是否正确
                            result.Message = "Ship to Code(Kids) is exist!";
                            return(Ok(result));
                        }
                    }
                }


                #endregion

                #region CURRENT_STATUS和 CURRENT_COMPSTATUS

                if (entity.TM_SEASON == "Q1")
                {
                    entity.CURRENT_STATUS     = entity.BLRQ1;
                    entity.CURRENT_COMPSTATUS = entity.COMPQ1;
                }
                else if (entity.TM_SEASON == "Q2")
                {
                    entity.CURRENT_STATUS     = entity.BLRQ2;
                    entity.CURRENT_COMPSTATUS = entity.COMPQ2;
                }
                else if (entity.TM_SEASON == "Q3")
                {
                    entity.CURRENT_STATUS     = entity.BLRQ3;
                    entity.CURRENT_COMPSTATUS = entity.COMPQ3;
                }
                else if (entity.TM_SEASON == "Q4")
                {
                    entity.CURRENT_STATUS     = entity.BLRQ4;
                    entity.CURRENT_COMPSTATUS = entity.COMPQ4;
                }

                #endregion
                await Repository.PostEntity(entity);

                result.Message   = "ok";
                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                result.Message = "" + ex.Message;
            }

            return(Ok(result));
        }
Ejemplo n.º 3
0
 public async Task PostEntity(POS_Master entity)
 {
     await Repository.PostEntity(entity);
 }
Ejemplo n.º 4
0
        public async Task <object> NonMandatoryInsertPOS_MasterInfo([FromQuery] string TM_YEAR, string TM_SEASON, string STC_Core, string POS_Status)
        {
            ResultModel result = new ResultModel();

            result.IsSuccess = false;
            try
            {
                if (string.IsNullOrEmpty(STC_Core))
                {
                    result.Message = "Ship to Code Core is Null Or Empty! ";
                    return(Ok(result));
                }
                POS_Master entity = new POS_Master();//一些默认值
                entity.POS_CHANNEL   = "Core";
                entity.TM_SEASON     = TM_SEASON;
                entity.TM_YEAR       = TM_YEAR;
                entity.STC_CORE      = STC_Core;
                entity.STA_BULK_CORE = "";
                entity.POS_Status    = POS_Status;
                entity.PackagePOS    = "N";
                string userid = HttpContext.User.Claims.Where(item => item.Type == System.Security.Claims.ClaimTypes.NameIdentifier).FirstOrDefault().Value;
                Users  _users = await userRepository.GetUserAndRoles(int.Parse(userid));

                entity.Modified_User = _users.name;
                entity.Created_Date  = DateTime.Now;

                //获取customerInfo
                CustomersInfo customersInfo = await CustomerRepository.GetSingleEntityByShipTo_Code(STC_Core);

                if (customersInfo == null)
                {
                    result.Message = "Ship to Code Core is Error![CustomersInfo]";
                    return(Ok(result));
                }
                entity.CUSTOMER_GROUP  = customersInfo.Customer_Group;
                entity.CUSTOMER_CODE   = customersInfo.Customer_Code;
                entity.CUSTOMER_NAME   = customersInfo.Customer_Name;
                entity.BRANCH_CN       = customersInfo.branch_CN;
                entity.BRANCH_EN       = customersInfo.branch_EN;
                entity.WHS_CHANNEL     = customersInfo.WHS_Channel;
                entity.Product_Channel = customersInfo.Product_Channel;


                #region 生成Dummy Code  即POS_CODE
                string paraname = "NN" + entity.TM_YEAR.Substring(2, 2) + entity.TM_SEASON + "-" + entity.CUSTOMER_GROUP + entity.BRANCH_EN + "-" + entity.POS_CHANNEL.Substring(0, 1);
                var    maxindex = Repository.GetMaxPOSCode(paraname);
                if (!string.IsNullOrEmpty(maxindex.ToString()))
                {
                    int index = int.Parse(maxindex.ToString());
                    if (index > 0)
                    {
                        index++;
                        entity.POS_CODE = paraname + (index < 10 ? "0" + index : index + "");
                    }
                    else
                    {
                        entity.POS_CODE = paraname + "01";
                    }
                }
                else
                {
                    entity.POS_CODE = paraname + "01";
                }
                #endregion

                #region 验证 ship to Code
                if (!string.IsNullOrEmpty(entity.STC_CORE))
                {
                    entity.STC_CORE = entity.STC_CORE.ToUpper();
                }
                if (entity.STC_CORE != "TBD" && !string.IsNullOrEmpty(entity.STC_CORE))
                {
                    //  string Productchannel = Repository.GetProductchannel(entity.STC_CORE);

                    if (entity.Product_Channel.ToLower() != "core")
                    {
                        result.Message = "Ship to Code(Core) is Error [Product_Channel]!";
                        return(Ok(result));
                    }
                    int reuslt = Repository.ExistshipCode(entity.STC_CORE, 1);
                    if (reuslt > 0)
                    {
                        //ship to code 是否正确
                        result.Message = "Ship to Code(Core) is exist!";
                        return(Ok(result));
                    }
                }
                #endregion
                #region CURRENT_STATUS和 CURRENT_COMPSTATUS 和BLR 一些状态的默认值

                entity.BLRQ1              = "N";
                entity.COMPQ1             = "N";
                entity.BLRQ2              = "N";
                entity.COMPQ2             = "N";
                entity.BLRQ3              = "N";
                entity.COMPQ3             = "N";
                entity.BLRQ4              = "N";
                entity.COMPQ4             = "N";
                entity.CURRENT_STATUS     = "N";
                entity.CURRENT_COMPSTATUS = "N";

                #endregion
                await Repository.PostEntity(entity);

                result.Message   = "ok";
                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                result.Message = "" + ex.Message;
            }

            return(Ok(result));
        }
Ejemplo n.º 5
0
        public async Task <object> GetSingleEntity(string TM_YEAR, string TM_SEASON, string POS_CODE)
        {
            POS_Master entity = await Repository.GetSingelEntity(TM_YEAR, TM_SEASON, POS_CODE);

            return(Ok(entity));
        }