public async Task <IResultModel> Update(MediaTypeUpdateModel model) { var entity = await _repository.FirstAsync(model.Id); if (entity == null) { return(ResultModel.NotExists); } _mapper.Map(model, entity); var result = await _repository.UpdateAsync(entity); return(ResultModel.Result(result)); }
public async Task <IResultModel> Edit(int id) { var entity = await _repository.GetAsync(id); if (entity == null) { return(ResultModel.NotExists); } var model = new MediaTypeUpdateModel { Ext = entity.Ext, Value = entity.Value }; return(ResultModel.Success(model)); }
public async Task <IResultModel> Update(MediaTypeUpdateModel model) { var entity = await _repository.GetAsync(model.Id); if (entity == null) { return(ResultModel.NotExists); } if (await _repository.Exists(model.Ext, model.Id)) { return(ResultModel.Failed("扩展名已存在")); } entity.Ext = model.Ext; entity.Value = model.Value; var result = await _repository.UpdateAsync(entity); return(ResultModel.Result(result)); }
public Task <IResultModel> Update(MediaTypeUpdateModel model) { return(_service.Update(model)); }