public async Task Update(int id, WorkingAvailability newValue)
        {
            if (!this.Exists(id))
            {
                throw new KeyNotFoundException();
            }
            var entity = await _context.WorkingAvailabilities.FirstOrDefaultAsync(w => w.Id == id);

            entity = newValue;
            _context.WorkingAvailabilities.Update(entity);
        }
Beispiel #2
0
        public async Task <ActionResult> PostWorkingAvailability([FromBody] WorkingAvailability workingAvailability)
        {
            try
            {
                await _workingAvailabilityRepository.Add(workingAvailability);
            }
            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("PostWorkingAvailability", new { workingAvailability.Id, workingAvailability }));
        }
 public async Task Add(WorkingAvailability toAdd)
 {
     _context.WorkingAvailabilities.Add(toAdd);
     await _context.SaveChangesAsync();
 }