public async Task <IActionResult> AddDoctorAbsence(AddDoctorAbsenceViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var doctor = await _doctorsRepository.GetDoctorByName(User.Identity.Name); var alreadyHasAbsence = await _absenceRepository.GetDoctorsAbscenceByDate(doctor.Name, model.AbsenceDate); if (alreadyHasAbsence != null) { return(RedirectToAction("Index", "Home")); } var absence = new DoctorAbsence { AbsenceDate = model.AbsenceDate, DoctorId = doctor.DoctorId, AbsenceDescription = model.AbsenceDescription }; await _absenceRepository.AddAbsence(absence); return(RedirectToAction("Index", "Home")); }
public void AddAbsence(Absence absence) { int x = GetAllAbsence().ToList().LastOrDefault().Id; //TODO: DELETE asa GUID is op absence.EmissionDate = DateTime.Now; //todo : initialize in front absence.Id = x + 1; //TODO: DELETE asa GUID is op absence.Status = "In progress"; //todo : initialize in front absenceRepository.AddAbsence(absence); }
public IActionResult Add(Absence absence) { PopulateEmployeesDropDown(absence.EmployeeID); if (!ModelState.IsValid) { return(View(absence)); } else { _absenceRepository.AddAbsence(absence); } return(View()); }