示例#1
0
        /// <summary>
        /// 经销商服务类型删除
        /// </summary>
        /// <returns></returns>
        public bool DeleteDistributorServiceType(DistributorServiceTypeOperateDTO dto)
        {
            bool blResult = false;

            using (var tcdmse = new Entities.TCDMS_MasterDataEntities())
            {
                var pp = tcdmse.master_DistributorServiceType.Where(p => p.DistributorServiceTypeID == dto.DistributorServiceTypeID).FirstOrDefault();
                if (pp == null)
                {
                    throw new Exception("此条信息不存在!");
                }
                if (pp.master_DistributorInfo.Count > 0)
                {
                    throw new Exception("此条信息已使用不可删除!");
                }

                tcdmse.master_DistributorServiceType.Remove(pp);
                // 记录日志
                this.AddLog(tcdmse, new LogData
                {
                    CurrentLogType = LogType.DELETE,
                    LogDetails     = "删除经销商服务类型" + pp.DistributorServiceTypeName,
                    OpratorName    = dto.ModifyUser
                });
                blResult = tcdmse.SaveChanges() > 0;
            }

            return(blResult);
        }
示例#2
0
        /// <summary>
        /// 经销商服务类型修改
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public static ResultData <object> UpdateDistributorServiceType(DistributorServiceTypeOperateDTO dto)
        {
            ResultData <object> result = null;

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

            return(result);
        }
示例#3
0
        public void TestMethod1()
        {
            //查询
            DistributorServiceTypeSearchDTO dto = new DistributorServiceTypeSearchDTO();
            string dtostr = Common.TransformHelper.ConvertDTOTOBase64JsonString(dto);
            var    pp     = DistributorServiceTypeController.GetDistributorServiceType(dtostr);

            //新增
            DistributorServiceTypeOperateDTO dto1 = new DistributorServiceTypeOperateDTO();

            dto1.DistributorServiceTypeName = "测试服务类型Test";
            dto1.CreateUser = "******";
            dto1.CreateTime = DateTime.Now;
            var                pp1        = DistributorServiceTypeController.AddDistributorServiceType(dto1);
            string             strResult1 = pp1.Content.ReadAsStringAsync().Result;
            ResultDTO <object> bl         = JsonConvert.DeserializeObject <ResultDTO <object> >(strResult1);

            Assert.IsTrue(bl.SubmitResult);

            //查询
            DistributorServiceTypeSearchDTO dto2 = new DistributorServiceTypeSearchDTO();
            string dto2str    = Common.TransformHelper.ConvertDTOTOBase64JsonString(dto2);
            var    pp2        = DistributorServiceTypeController.GetDistributorServiceType(dto2str);
            string strResult2 = pp2.Content.ReadAsStringAsync().Result;
            List <DistributorServiceTypeResultDTO> list1 = JsonConvert.DeserializeObject <List <DistributorServiceTypeResultDTO> >(strResult2);

            //修改
            DistributorServiceTypeOperateDTO dto3 = new DistributorServiceTypeOperateDTO();

            dto3.DistributorServiceTypeID   = list1.Where(p => p.DistributorServiceTypeName == "测试服务类型Test").Select(s => s.DistributorServiceTypeID).FirstOrDefault();
            dto3.DistributorServiceTypeName = "修改测试服务类型Test";
            dto3.ModifyUser = "******";
            dto3.ModifyTime = DateTime.Now;
            var                pp3        = DistributorServiceTypeController.UpdateDistributorServiceType(dto3);
            string             strResult3 = pp3.Content.ReadAsStringAsync().Result;
            ResultDTO <object> bl1        = JsonConvert.DeserializeObject <ResultDTO <object> >(strResult3);

            Assert.IsTrue(bl1.SubmitResult);

            //删除
            DistributorServiceTypeOperateDTO dto4 = new DistributorServiceTypeOperateDTO();

            dto4.DistributorServiceTypeID = list1.Where(p => p.DistributorServiceTypeName == "测试服务类型Test").Select(s => s.DistributorServiceTypeID).FirstOrDefault();
            string             dto4str    = Common.TransformHelper.ConvertDTOTOBase64JsonString(dto4);
            var                pp4        = DistributorServiceTypeController.DeleteDistributorServiceType(dto4str);
            string             strResult4 = pp4.Content.ReadAsStringAsync().Result;
            ResultDTO <object> bl2        = JsonConvert.DeserializeObject <ResultDTO <object> >(strResult4);

            Assert.IsTrue(bl2.SubmitResult);
        }
示例#4
0
        /// <summary>
        /// 经销商服务类型修改
        /// </summary>
        /// <returns></returns>
        public bool UpdateDistributorServiceType(DistributorServiceTypeOperateDTO dto)
        {
            bool blResult = false;

            using (var tcdmse = new Entities.TCDMS_MasterDataEntities())
            {
                var pp = tcdmse.master_DistributorServiceType.Where(p => p.DistributorServiceTypeID == dto.DistributorServiceTypeID).FirstOrDefault();
                if (pp == null)
                {
                    throw new Exception("此条信息不存在!");
                }
                pp.DistributorServiceTypeName = dto.DistributorServiceTypeName;
                pp.ModifyUser = dto.ModifyUser;
                pp.ModifyTime = dto.ModifyTime;

                blResult = tcdmse.SaveChanges() > 0;
            }

            return(blResult);
        }
示例#5
0
        public void TestMethod2()
        {
            //查询经销商服务类型
            DistributorServiceTypeSearchDTO        dto  = new DistributorServiceTypeSearchDTO();
            List <DistributorServiceTypeResultDTO> list = _IDistributorServices.GetDistributorServiceType(dto);

            //经销商服务类型新增
            DistributorServiceTypeOperateDTO dto1 = new DistributorServiceTypeOperateDTO();

            dto1.DistributorServiceTypeName = "测试服务类型Test";
            dto1.CreateUser = "******";
            dto1.CreateTime = DateTime.Now;
            bool bl = _IDistributorServices.AddDistributorServiceType(dto1);

            Assert.IsTrue(bl);

            //查询经销商服务类型
            DistributorServiceTypeSearchDTO        dto2  = new DistributorServiceTypeSearchDTO();
            List <DistributorServiceTypeResultDTO> list1 = _IDistributorServices.GetDistributorServiceType(dto2);

            //修改经销商服务类型
            DistributorServiceTypeOperateDTO dto3 = new DistributorServiceTypeOperateDTO();

            dto3.DistributorServiceTypeID   = list1.Where(p => p.DistributorServiceTypeName == "测试服务类型Test").Select(s => s.DistributorServiceTypeID).FirstOrDefault();
            dto3.DistributorServiceTypeName = "修改测试服务类型Test";
            dto3.ModifyUser = "******";
            dto3.ModifyTime = DateTime.Now;
            bool bl1 = _IDistributorServices.UpdateDistributorServiceType(dto3);

            Assert.IsTrue(bl1);

            //删除经销商服务类型
            DistributorServiceTypeOperateDTO dto4 = new DistributorServiceTypeOperateDTO();

            dto4.DistributorServiceTypeID = list1.Where(p => p.DistributorServiceTypeName == "测试服务类型Test").Select(s => s.DistributorServiceTypeID).FirstOrDefault();
            bool bl2 = _IDistributorServices.DeleteDistributorServiceType(dto4);

            Assert.IsTrue(bl2);
        }
示例#6
0
        public HttpResponseMessage AddDistributorServiceType(DistributorServiceTypeOperateDTO dto)
        {
            ResultDTO <object> actionresult = new ResultDTO <object>();

            try
            {
                actionresult.SubmitResult = _IDistributorServices.AddDistributorServiceType(dto);
            }
            catch (Exception ex)
            {
                actionresult.SubmitResult = false;
                actionresult.Message      = ex.Message;
            }
            HttpResponseMessage result = new HttpResponseMessage
            {
                Content = new StringContent(JsonConvert.SerializeObject(actionresult),
                                            System.Text.Encoding.GetEncoding("UTF-8"),
                                            "application/json")
            };

            return(result);
        }
示例#7
0
        /// <summary>
        /// 经销商服务类型新增
        /// </summary>
        /// <returns></returns>
        public bool AddDistributorServiceType(DistributorServiceTypeOperateDTO dto)
        {
            bool blResult = false;

            using (var tcdmse = new Entities.TCDMS_MasterDataEntities())
            {
                master_DistributorServiceType distype = new master_DistributorServiceType();
                Mapper.Map <DistributorServiceTypeOperateDTO, master_DistributorServiceType>(dto, distype);

                tcdmse.master_DistributorServiceType.Add(distype);
                // 记录日志
                this.AddLog(tcdmse, new LogData
                {
                    CurrentLogType = LogType.ADD,
                    LogDetails     = "新增经销商服务类型" + dto.DistributorServiceTypeName,
                    OpratorName    = dto.CreateUser
                });
                blResult = tcdmse.SaveChanges() > 0;
            }

            return(blResult);
        }
示例#8
0
        public HttpResponseMessage DeleteDistributorServiceType(string DistributorServiceTypeOperateDTO)
        {
            DistributorServiceTypeOperateDTO dto = TransformHelper.ConvertBase64JsonStringToDTO <DistributorServiceTypeOperateDTO>(DistributorServiceTypeOperateDTO);
            ResultDTO <object> actionresult      = new ResultDTO <object>();

            try
            {
                actionresult.SubmitResult = _IDistributorServices.DeleteDistributorServiceType(dto);
            }
            catch (Exception ex)
            {
                actionresult.SubmitResult = false;
                actionresult.Message      = ex.Message;
            }
            HttpResponseMessage result = new HttpResponseMessage
            {
                Content = new StringContent(JsonConvert.SerializeObject(actionresult),
                                            System.Text.Encoding.GetEncoding("UTF-8"),
                                            "application/json")
            };

            return(result);
        }
示例#9
0
        /// <summary>
        /// 经销商服务类型删除
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        public static ResultData <object> DeleteDistributorServiceType(DistributorServiceTypeOperateDTO dto)
        {
            ResultData <object> blResult = DeleteAPI <ResultData <object> >(WebConfiger.MasterDataServicesUrl + "DistributorServiceType?DistributorServiceTypeOperateDTO=" + TransformHelper.ConvertDTOTOBase64JsonString(dto));

            return(blResult);
        }