Esempio n. 1
0
        /// <summary>
        /// 新增经销商公告授权
        /// </summary>
        /// <returns></returns>
        public bool AddDistributorAnnounceAuthority(DistributorAnnounceAuthorityOperateDTO dto)
        {
            bool result = false;

            using (var tcdmse = new Entities.TCDMS_MasterDataEntities())
            {
                var pp = tcdmse.master_DistributorInfo.AsNoTracking().Where(p => p.DistributorID == dto.DistributorID).FirstOrDefault();
                if (pp == null)
                {
                    pp = tcdmse.master_DistributorInfo.Where(p => p.DistributorName == dto.DistributorName).FirstOrDefault();
                    if (pp == null)
                    {
                        throw new Exception("经销商不存在!");
                    }
                }
                var remove = tcdmse.master_DistributorADInfo.Where(p => p.DistributorID == pp.DistributorID);
                tcdmse.master_DistributorADInfo.RemoveRange(remove);
                if (dto.ProductLineIDList.Count > 0)
                {
                    foreach (var id in dto.ProductLineIDList)
                    {
                        master_DistributorADInfo newitem = new master_DistributorADInfo();
                        newitem.DistributorID = pp.DistributorID;
                        newitem.ProductLineID = id;
                        newitem.CreateTime    = dto.CreateTime;
                        newitem.CreateUser    = dto.CreateUser;
                        tcdmse.master_DistributorADInfo.Add(newitem);
                    }
                }

                result = tcdmse.SaveChanges() > 0;
            }

            return(result);
        }
Esempio n. 2
0
        /// <summary>
        /// 新增经销商公告授权
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public static ResultData <object> AddDistributorAnnounceAuthority(DistributorAnnounceAuthorityOperateDTO dto)
        {
            dto.ProductLineIDList = dto.ProductLineIDList.Where(p => p.HasValue).ToList();
            ResultData <object> result = null;

            result = PostAPI <ResultData <object> >(WebConfiger.MasterDataServicesUrl + "DistributorAnnounceAuthority", dto);

            return(result);
        }
Esempio n. 3
0
        public HttpResponseMessage AddDistributorAnnounceAuthority(DistributorAnnounceAuthorityOperateDTO dto)
        {
            ResultDTO <object> actionresult = new ResultDTO <object>();

            try
            {
                actionresult.SubmitResult = _IDistributorServices.AddDistributorAnnounceAuthority(dto);
            }
            catch (Exception e)
            {
                actionresult.SubmitResult = false;
                actionresult.Message      = e.Message;
            }

            HttpResponseMessage result = new HttpResponseMessage
            {
                Content = new StringContent(JsonConvert.SerializeObject(actionresult),
                                            System.Text.Encoding.GetEncoding("UTF-8"),
                                            "application/json")
            };

            return(result);
        }