Esempio n. 1
0
 public IActionResult Post(Guid rosterId, string code, [FromBody] Shift item)
 {
     if (item == null || item.RosterId != rosterId || item.Code != code)
     {
         return(BadRequest());
     }
     _context.Shifts.Add(ServerShift.FromShift(item));
     _context.SaveChanges();
     return(CreatedAtRoute(new { item.RosterId, item.Code }, item));
 }
Esempio n. 2
0
        public IActionResult Put(Guid rosterId, string code, [FromBody] Shift item)
        {
            if (item == null || item.Code != code || item.RosterId != rosterId)
            {
                return(BadRequest());
            }
            var existing = _context.Shifts.Find(rosterId, code);

            if (existing == null)
            {
                return(NotFound());
            }
            _context.Entry(existing).CurrentValues.SetValues(ServerShift.FromShift(item));
            _context.SaveChanges();
            return(new NoContentResult());
        }