コード例 #1
0
        public bool CreateTestSetting(TestSettingModel model)
        {
            var entity = MappingUtil.Map <TestSettingModel, TestSetting>(model);

            _uow.TestSettings.Add(entity);
            _uow.SaveChanges();

            MappingUtil.Map(entity, model);

            return(true);
        }
コード例 #2
0
        public TestSettingModel GetTestSetting(int id)
        {
            TestSettingModel model = null;
            var entity             = _uow.TestSettings.GetById(id);

            if (entity != null)
            {
                model = MappingUtil.Map <TestSetting, TestSettingModel>(entity);
            }

            return(model);
        }
コード例 #3
0
        public bool UpdateTestSetting(TestSettingModel model)
        {
            var entity = MappingUtil.Map <TestSettingModel, TestSetting>(model);

            try {
                _uow.TestSettings.Update(entity);
                _uow.SaveChanges();
            }
            catch (Exception ex)
            {
                _loggingSvc.Log(ex);
                return(false);
            }

            return(true);
        }
コード例 #4
0
        public HttpResponseMessage Patch([FromBody] TestSettingModel model)
        {
            try
            {
                if (ModelState.IsValid == false || _testSettingSvc.UpdateTestSetting(model) == false)
                {
                    return(Request.CreateResponse(HttpStatusCode.BadRequest, ModelState));
                }

                return(Request.CreateResponse(HttpStatusCode.OK, model));
            }
            catch (ServiceException ex)
            {
                return(Request.CreateResponse(ex.HttpStatusCode, ex.Message));
            }
        }