/// <summary> /// 经销商类别删除 /// </summary> /// <returns></returns> public bool DeleteDistributorType(DistributorTypeOperateDTO dto) { bool blResult = false; using (var tcdmse = new Entities.TCDMS_MasterDataEntities()) { var pp = tcdmse.master_DistributorType.Where(p => p.DistributorTypeID == dto.DistributorTypeID).FirstOrDefault(); if (pp == null) { throw new Exception("此条信息不存在!"); } if (pp.master_DistributorInfo.Count > 0) { throw new Exception("此条信息已使用不可删除!"); } tcdmse.master_DistributorType.Remove(pp); // 记录日志 this.AddLog(tcdmse, new LogData { CurrentLogType = LogType.DELETE, LogDetails = "删除经销商类别" + pp.DistributorTypeName, OpratorName = dto.ModifyUser }); blResult = tcdmse.SaveChanges() > 0; } return(blResult); }
/// <summary> /// 经销商类别修改 /// </summary> /// <param name="dto"></param> /// <returns></returns> public static ResultData <object> UpdateDistributorType(DistributorTypeOperateDTO dto) { ResultData <object> result = null; result = PutAPI <ResultData <object> >(WebConfiger.MasterDataServicesUrl + "DistributorType", dto); return(result); }
public void TestMethod1() { //查询 DistributorTypeSearchDTO dto = new DistributorTypeSearchDTO(); string dtostr = Common.TransformHelper.ConvertDTOTOBase64JsonString(dto); var pp = DistributorTypeController.GetDepartmentList(dtostr); //新增 DistributorTypeOperateDTO dto1 = new DistributorTypeOperateDTO(); dto1.DistributorTypeName = "测试类别Test"; dto1.CreateUser = "******"; dto1.CreateTime = DateTime.Now; var pp1 = DistributorTypeController.AddDistributorType(dto1); string strResult1 = pp1.Content.ReadAsStringAsync().Result; ResultDTO <object> bl = JsonConvert.DeserializeObject <ResultDTO <object> >(strResult1); Assert.IsTrue(bl.SubmitResult); //查询 DistributorTypeSearchDTO dto2 = new DistributorTypeSearchDTO(); string dto2str = Common.TransformHelper.ConvertDTOTOBase64JsonString(dto2); var pp2 = DistributorTypeController.GetDepartmentList(dto2str); string strResult2 = pp2.Content.ReadAsStringAsync().Result; List <DistributorTypeResultDTO> list1 = JsonConvert.DeserializeObject <List <DistributorTypeResultDTO> >(strResult2); //修改 DistributorTypeOperateDTO dto3 = new DistributorTypeOperateDTO(); dto3.DistributorTypeID = list1.Where(p => p.DistributorTypeName == "测试类别Test").Select(s => s.DistributorTypeID).FirstOrDefault(); dto3.DistributorTypeName = "修改测试类别Test"; dto3.ModifyUser = "******"; dto3.ModifyTime = DateTime.Now; var pp3 = DistributorTypeController.UpdateDistributorType(dto3); string strResult3 = pp3.Content.ReadAsStringAsync().Result; ResultDTO <object> bl1 = JsonConvert.DeserializeObject <ResultDTO <object> >(strResult3); Assert.IsTrue(bl1.SubmitResult); //删除 DistributorTypeOperateDTO dto4 = new DistributorTypeOperateDTO(); dto4.DistributorTypeID = list1.Where(p => p.DistributorTypeName == "测试类别Test").Select(s => s.DistributorTypeID).FirstOrDefault(); string dto4str = Common.TransformHelper.ConvertDTOTOBase64JsonString(dto4); var pp4 = DistributorTypeController.DeleteDistributorType(dto4str); string strResult4 = pp4.Content.ReadAsStringAsync().Result; ResultDTO <object> bl2 = JsonConvert.DeserializeObject <ResultDTO <object> >(strResult4); Assert.IsTrue(bl2.SubmitResult); }
/// <summary> /// 经销商类别修改 /// </summary> /// <returns></returns> public bool UpdateDistributorType(DistributorTypeOperateDTO dto) { bool blResult = false; using (var tcdmse = new Entities.TCDMS_MasterDataEntities()) { var pp = tcdmse.master_DistributorType.Where(p => p.DistributorTypeID == dto.DistributorTypeID).FirstOrDefault(); if (pp == null) { throw new Exception("此条信息不存在!"); } pp.DistributorTypeName = dto.DistributorTypeName; pp.ModifyUser = dto.ModifyUser; pp.ModifyTime = dto.ModifyTime; blResult = tcdmse.SaveChanges() > 0; } return(blResult); }
public void TestMethod1() { //查询经销商类别 DistributorTypeSearchDTO dto = new DistributorTypeSearchDTO(); List <DistributorTypeResultDTO> list = _IDistributorServices.GetDistributorType(dto); //经销商类别新增 DistributorTypeOperateDTO dto1 = new DistributorTypeOperateDTO(); dto1.DistributorTypeName = "测试类别Test"; dto1.CreateUser = "******"; dto1.CreateTime = DateTime.Now; bool bl = _IDistributorServices.AddDistributorType(dto1); Assert.IsTrue(bl); //查询经销商类别 DistributorTypeSearchDTO dto2 = new DistributorTypeSearchDTO(); List <DistributorTypeResultDTO> list1 = _IDistributorServices.GetDistributorType(dto2); //修改经销商类别 DistributorTypeOperateDTO dto3 = new DistributorTypeOperateDTO(); dto3.DistributorTypeID = list1.Where(p => p.DistributorTypeName == "测试类别Test").Select(s => s.DistributorTypeID).FirstOrDefault(); dto3.DistributorTypeName = "修改测试类别Test"; dto3.ModifyUser = "******"; dto3.ModifyTime = DateTime.Now; bool bl1 = _IDistributorServices.UpdateDistributorType(dto3); Assert.IsTrue(bl1); //删除经销商类别 DistributorTypeOperateDTO dto4 = new DistributorTypeOperateDTO(); dto4.DistributorTypeID = list1.Where(p => p.DistributorTypeName == "测试类别Test").Select(s => s.DistributorTypeID).FirstOrDefault(); bool bl2 = _IDistributorServices.DeleteDistributorType(dto4); Assert.IsTrue(bl2); }
public HttpResponseMessage AddDistributorType(DistributorTypeOperateDTO dto) { ResultDTO <object> actionresult = new ResultDTO <object>(); try { actionresult.SubmitResult = _IDistributorServices.AddDistributorType(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); }
/// <summary> /// 经销商类别新增 /// </summary> /// <returns></returns> public bool AddDistributorType(DistributorTypeOperateDTO dto) { bool blResult = false; using (var tcdmse = new Entities.TCDMS_MasterDataEntities()) { master_DistributorType distype = new master_DistributorType(); Mapper.Map <DistributorTypeOperateDTO, master_DistributorType>(dto, distype); tcdmse.master_DistributorType.Add(distype); // 记录日志 this.AddLog(tcdmse, new LogData { CurrentLogType = LogType.ADD, LogDetails = "新增经销商类别" + dto.DistributorTypeName, OpratorName = dto.CreateUser }); blResult = tcdmse.SaveChanges() > 0; } return(blResult); }
public HttpResponseMessage DeleteDistributorType(string DistributorTypeOperateDTO) { DistributorTypeOperateDTO dto = TransformHelper.ConvertBase64JsonStringToDTO <DistributorTypeOperateDTO>(DistributorTypeOperateDTO); ResultDTO <object> actionresult = new ResultDTO <object>(); try { actionresult.SubmitResult = _IDistributorServices.DeleteDistributorType(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); }
/// <summary> /// 经销商类别删除 /// </summary> /// <param name="dto"></param> /// <returns></returns> public static ResultData <object> DeleteDistributorType(DistributorTypeOperateDTO dto) { ResultData <object> blResult = DeleteAPI <ResultData <object> >(WebConfiger.MasterDataServicesUrl + "DistributorType?DistributorTypeOperateDTO=" + TransformHelper.ConvertDTOTOBase64JsonString(dto)); return(blResult); }