public async Task <IActionResult> PutInpatientBookingNurses([FromBody] HandoverParameter handover) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var currentBookings = (await _context.InpatientBookings.Where(ip => handover.InpatientBookingIds.Contains(ip.InpatientBookingId)) .Select(ip => new InpatientBooking() { InpatientBookingId = ip.InpatientBookingId, ResponsibleNurseId = ip.ResponsibleNurseId, }).ToListAsync()); foreach (var booking in currentBookings) { booking.ResponsibleNurseId = handover.HandoverNurseId; _context.Entry(booking).Property(b => b.ResponsibleNurseId).IsModified = true; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } return(NoContent()); }
async Task IInpatientBookingServiceInternal.UpdateObservationFrequency(int inpatientBookingId, int frequencyInMinutes) { var booking = await _context.InpatientBookings.Where(ip => ip.InpatientBookingId == inpatientBookingId).Select(ip => new InpatientBooking() { InpatientBookingId = ip.InpatientBookingId, ObservationFrequencyInMinutes = ip.ObservationFrequencyInMinutes, ObservationDue = ip.ObservationDue }).FirstOrDefaultAsync(); booking.ObservationFrequencyInMinutes = frequencyInMinutes; if (DateTime.Now.AddMinutes(frequencyInMinutes) is DateTime newDateTime && (!booking.ObservationDue.HasValue || newDateTime < booking.ObservationDue)) { booking.ObservationDue = newDateTime; } _context.Entry(booking).Property(b => b.ObservationDue).IsModified = true; _context.Entry(booking).Property(b => b.ObservationFrequencyInMinutes).IsModified = true; await _context.SaveChangesAsync(); }