예제 #1
0
        public async Task <PropertyViewModel> UpdatePropertyAsync(int id, PropertyUpdateModel model, User theOperator)
        {
            var property = await _propertyDataService.UpdateAsync(id, x => Mapper.Map(model, x), true, theOperator);

            var toReturn = Mapper.Map <PropertyViewModel>(property);

            return(toReturn);
        }
예제 #2
0
        public async Task <IResultModel> Update(PropertyUpdateModel model)
        {
            var entity = await _repository.GetAsync(model.Id);

            if (entity == null)
            {
                return(ResultModel.NotExists);
            }

            _mapper.Map(model, entity);

            if (await _repository.Exists(entity))
            {
                return(ResultModel.Failed($"属性名称({entity.Name})已存在"));
            }

            var result = await _repository.UpdateAsync(entity);

            return(ResultModel.Result(result));
        }
예제 #3
0
 public Task <IResultModel> Update(PropertyUpdateModel model)
 {
     return(_service.Update(model));
 }
예제 #4
0
 public async Task <IHttpActionResult> Put(int id, PropertyUpdateModel model)
 {
     return(Ok(await _propertyService.UpdatePropertyAsync(id, model, this.GetOperator(_userService))));
 }