public async Task <Schedule> ChangeScheduleStatus(ChangeScheduleStatusRequest request) { var schedule = await _unitOfWork.GetRepository <Schedule>().FindAsync(x => x.Id == request.Id); schedule.Status = request.Status; _unitOfWork.GetRepository <Schedule>().Update(schedule); if (request.Status == 5) { var shift = await _unitOfWork.GetRepository <Shift>().GetAll().FirstOrDefaultAsync(x => x.Id == schedule.ShiftId); var service = await _unitOfWork.GetRepository <CS.EF.Models.Services>().FindAsync(x => x.RoomId == shift.RoomId); var invoice = new Invoice { Id = new Guid(), CreatedDate = DateTime.Now, PatientId = schedule.PatientId, ScheduleId = schedule.Id, Content = "Khám bệnh" + service.Name.Remove(0, 2).ToLower(), Cost = service.Cost, CreateBy = "SYSTEM", Status = 1 }; _unitOfWork.GetRepository <Invoice>().Add(invoice); } await _unitOfWork.CommitAsync(); return(schedule); }
public async Task <IActionResult> ChangeScheduleStatus(ChangeScheduleStatusRequest request) { var response = await _shiftService.ChangeScheduleStatus(request); return(Ok(new ApiOkResponse(response))); }