Exemplo n.º 1
0
        public APIResult ProjectShopExamTypeImport(UploadData uploadData)
        {
            try
            {
                List <ProjectShopExamTypeDto> list = CommonHelper.DecodeString <List <ProjectShopExamTypeDto> >(uploadData.ListJson);
                //验证Excel中的经销商代码和卷别代码是否在系统存在
                foreach (ProjectShopExamTypeDto projectShopExamTypeDto in list)
                {
                    List <ShopDto> shopList = masterService.GetShop("", projectShopExamTypeDto.BrandId.ToString(), "", projectShopExamTypeDto.ShopCode, "");
                    if (shopList == null || shopList.Count == 0)
                    {
                        return(new APIResult()
                        {
                            Status = false, Body = "导入失败,文件中存在在系统未登记的经销商代码,请检查文件"
                        });
                    }
                    List <Label> labelList = masterService.GetLabel(projectShopExamTypeDto.BrandId.ToString(), "", "ExamType", true, projectShopExamTypeDto.ExamTypeCode);
                    if (labelList == null || labelList.Count == 0)
                    {
                        return(new APIResult()
                        {
                            Status = false, Body = "导入失败,文件中存在在系统未登记或者不可用的卷别代码,请检查文件"
                        });
                    }
                }
                foreach (ProjectShopExamTypeDto projectShopExamTypeDto in list)
                {
                    ProjectShopExamType projectShopExamType = new ProjectShopExamType();
                    projectShopExamType.ProjectId = projectShopExamTypeDto.ProjectId;
                    List <ShopDto> shopList = masterService.GetShop("", projectShopExamTypeDto.BrandId.ToString(), "", projectShopExamTypeDto.ShopCode, "");
                    if (shopList != null && shopList.Count > 0)
                    {
                        projectShopExamType.ShopId = shopList[0].ShopId;
                    }
                    List <Label> labelList = masterService.GetLabel(projectShopExamTypeDto.BrandId.ToString(), "", "ExamType", true, projectShopExamTypeDto.ExamTypeCode);
                    if (labelList != null && labelList.Count > 0)
                    {
                        projectShopExamType.ExamTypeId = labelList[0].LabelId;
                    }
                    projectShopExamType.InUserId     = projectShopExamTypeDto.InUserId;
                    projectShopExamType.ModifyUserId = projectShopExamTypeDto.ModifyUserId;

                    shopService.SaveProjectShopExamType(projectShopExamType);
                }
                return(new APIResult()
                {
                    Status = true, Body = ""
                });
            }
            catch (Exception ex)
            {
                return(new APIResult()
                {
                    Status = false, Body = ex.Message.ToString()
                });
            }
        }
        /// <summary>
        /// 保存经销商卷别类型
        /// </summary>
        /// <param name="projectShopExamType"></param>
        public void SaveProjectShopExamType(ProjectShopExamType projectShopExamType)
        {
            ProjectShopExamType findOne = db.ProjectShopExamType.Where(x => (x.ProjectId == projectShopExamType.ProjectId && x.ShopId == projectShopExamType.ShopId)).FirstOrDefault();

            if (findOne == null)
            {
                projectShopExamType.InDateTime     = DateTime.Now;
                projectShopExamType.ModifyDateTime = DateTime.Now;
                db.ProjectShopExamType.Add(projectShopExamType);
            }
            else
            {
                findOne.ExamTypeId     = projectShopExamType.ExamTypeId;
                findOne.ModifyDateTime = DateTime.Now;
                findOne.ModifyUserId   = projectShopExamType.ModifyUserId;
            }
            db.SaveChanges();
        }
Exemplo n.º 3
0
 public APIResult SaveProjectShopExamType(ProjectShopExamType projectShopExamType)
 {
     try
     {
         shopService.SaveProjectShopExamType(projectShopExamType);
         return(new APIResult()
         {
             Status = true, Body = ""
         });
     }
     catch (Exception ex)
     {
         return(new APIResult()
         {
             Status = false, Body = ex.Message.ToString()
         });
     }
 }