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); }