示例#1
0
        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"));
        }
示例#2
0
        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);
        }
示例#3
0
 public IActionResult Add(Absence absence)
 {
     PopulateEmployeesDropDown(absence.EmployeeID);
     if (!ModelState.IsValid)
     {
         return(View(absence));
     }
     else
     {
         _absenceRepository.AddAbsence(absence);
     }
     return(View());
 }