public async Task Update(int id, WorkingGroupSchedule newValue) { if (!this.Exists(id)) { throw new KeyNotFoundException(); } var entity = await _context.WorkingGroupSchedules.FirstOrDefaultAsync(w => w.Id == id); entity = newValue; _context.WorkingGroupSchedules.Update(entity); }
public async Task <ActionResult> PostWorkingGroupSchedule([FromBody] WorkingGroupSchedule workingGroupSchedule) { try { await _workingGroupScheduleRepository.Add(workingGroupSchedule); } catch (DbUpdateConcurrencyException e) { _logger.LogError(e.Message); return(Problem(e.Message)); } catch (DbUpdateException e) { _logger.LogError(e.Message); return(Problem(e.Message)); } catch (Exception e) { _logger.LogError(e.Message); return(Problem(e.Message)); } return(CreatedAtAction("PostWorkingScheduleGroup", new { workingGroupSchedule.Id, workingGroupSchedule })); }
public async Task Add(WorkingGroupSchedule toAdd) { _context.WorkingGroupSchedules.Add(toAdd); await _context.SaveChangesAsync(); }