public async Task <IActionResult> Post([FromBody] RecurringSheetEntryDTO value) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } RecurringSheetEntry entry = this._mappingEngine.Map <RecurringSheetEntryDTO, RecurringSheetEntry>(value); this.EntityOwnerService.AssignOwner(entry, this.OwnerId); entry.SortOrder = this._recurringSheetEntryRepository.FindNextSortOrder(this.OwnerId); this._recurringSheetEntryRepository.Add(entry); await this._recurringSheetEntryRepository.SaveChangesAsync(); return(this.CreatedAtRoute("RecurringSheetEntry-Get", new { id = entry.Id }, await this.Get(entry.Id))); }
public async Task <IActionResult> Put(int id, [FromBody] RecurringSheetEntryDTO value) { if (!this.ModelState.IsValid) { return(this.BadRequest(this.ModelState)); } RecurringSheetEntry entry = await this.GetEntityByIdAsync(id); this.EntityOwnerService.EnsureOwner(entry, this.OwnerId); this._mappingEngine.Map(value, entry); await this._recurringSheetEntryRepository.SaveChangesAsync(); return(this.NoContent()); }