public static Cat ToEntity(this CatUpdateDto cat) { return(new Cat { CatId = cat.Id, Name = cat.Name, BirthDate = cat.BirthDate, Weights = cat.Weights.Select(x => new Weight { Date = x.Key, Grams = x.Value }).ToList() }); }
private IServiceTest Execute() { using (var context = new CatSharpContext(base.Options)) { // Get the cat created var cat = context.Cats.AsNoTracking().Single(x => x.Name.Equals("Cat 1")); // Simulate the return value as CatGetDto var oldDto = cat.ToDto(); // Create the new CatUpdateDto with the date to be updated var newDto = new CatUpdateDto(oldDto.Id, "Cat B", oldDto.BirthDate, oldDto.Weights); // Update var service = new CatService(context); service.Update(newDto); } return(this); }
private Cat Map(CatUpdateDto cat) { return(cat.ToEntity()); }
public void Update(CatUpdateDto cat) { _context.Update(Map(cat)); _context.SaveChanges(); }
public void Put([FromBody] CatUpdateDto cat) { _service.Update(cat); }