public ActionResult UpdateCoreMVC(int id, DealerUpdateDto coreMVCUpdateDto) { var dealerFromRepo = _dealerRepo.GetDealerInfoById(id); if (dealerFromRepo == null) { return(NotFound()); } _mapper.Map(coreMVCUpdateDto, dealerFromRepo); // *1 //note that we do not have implementation in our sql repository, //this mapping exercise here has basically done is its actually updated //coreMVCModelFromRepo and changes are actually being tracked via dbcontext, //we dont actually need to do anything else w/ it other than save changes (need to flush it down to our db) //in interest of maintaining separate interface from implementation, //good practice is still to call update method on our repository and supply in our model from repo //because other implementations may require us to to that //even though it is counterintuitive _dealerRepo.UpdateDealerInfo(dealerFromRepo); //flush down changes to the db that were made at (*1) _dealerRepo.SaveChanges(); return(NoContent()); }
public async Task <DealerDTO> PatchAsync(DealerUpdateDto dealer) { this.Logger.LogTrace($"{nameof(this.PutAsync)} called"); var result = await this.DealerService.UpdateAsync(this.Mapper.Map <DealerUpdateModel>(dealer)); return(this.Mapper.Map <DealerDTO>(result)); }