public RationDay UpdateDay(RationDay day) { var days = GetDays(); if (day.Id != Guid.Empty) { var toUpdate = days.FirstOrDefault(i => i.Id == day.Id); if (toUpdate != null) { int index = days.IndexOf(toUpdate); days[index] = day; } SaveDays(days); return(day); } // Day.Id == Guid.Empty var newDay = new RationDay(Guid.NewGuid()); newDay.CopyPropertiesFrom(day); days.Add(newDay); SaveDays(days); return(newDay); }
public async Task <ActionResult <RationDay> > UpdateDay(RationDay day) { var updateCommand = new UpdateDayCommand(day); var response = await _mediator.Send(updateCommand); return(Ok(response)); }