Exemplo n.º 1
0
        public void TestMethod2()
        {
            //查询仪器类型
            List <InstrumentTypeResultDTO> list = _IProductServices.GetInstrumentTypeList();

            //新增仪器类型
            InstrumentTypeOperateDTO dto1 = new InstrumentTypeOperateDTO();

            dto1.InstrumentTypeName = "测试仪器类型Test";
            dto1.CreateUser         = "******";
            dto1.CreateTime         = DateTime.Now;
            bool bl = _IProductServices.AddInstrumentType(dto1);

            Assert.IsTrue(bl);

            //查询仪器类型
            List <InstrumentTypeResultDTO> list1 = _IProductServices.GetInstrumentTypeList();

            list1 = list1.Where(p => p.InstrumentTypeName == "测试仪器类型Test").ToList();

            //修改仪器类型
            InstrumentTypeOperateDTO dto3 = new InstrumentTypeOperateDTO();

            dto3.InstrumentTypeID   = list1.Select(s => s.InstrumentTypeID).FirstOrDefault();
            dto3.InstrumentTypeName = "测试仪器类型Test";
            dto3.ModifyUser         = "******";
            dto3.ModifyTime         = DateTime.Now;
            bool bl1 = _IProductServices.UpdateInstrumentType(dto3);

            Assert.IsTrue(bl1);

            //删除仪器类型
            InstrumentTypeSearchDTO dto5 = new InstrumentTypeSearchDTO();

            dto5.InstrumentTypeID = list1.Select(s => s.InstrumentTypeID).FirstOrDefault();
            bool bl3 = _IProductServices.DeleteInstrumentType(dto5);

            Assert.IsTrue(bl3);
        }
Exemplo n.º 2
0
        public HttpResponseMessage AddInstrumentType(InstrumentTypeOperateDTO dto)
        {
            ResultDTO <object> actionresult = new ResultDTO <object>();

            try
            {
                actionresult.SubmitResult = _IIProductServices.AddInstrumentType(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);
        }