public ActionResult EmployeeReservation(AddUserResevation reservation)
        {
            if (!ModelState.IsValid)
            {
                return(View(reservation));
            }
            var model         = new PROJECT_EMPLOYEES_RESERVATION();
            var modelEmployee = new PROJECT_EMPLOYEES();

            model.EmployeeId     = _employeeId;
            model.ProjectOwnerId = GetLoggedUserId();
            model.BeginDate      = reservation.BeginDate;
            model.EndDate        = reservation.EndDate;
            model.Extent         = reservation.Extent;
            model.ProjectCode    = reservation.ProjectCode;

            var      ReservationList    = dbOperations.GetEmployeeReservation(model.EmployeeId);
            TimeSpan beginDifference    = new TimeSpan();
            TimeSpan endDifference      = new TimeSpan();
            TimeSpan beginEndDifference = new TimeSpan();
            TimeSpan EndbeginDifference = new TimeSpan();
            TimeSpan zero             = new TimeSpan(0, 0, 0, 0);
            var      sequenceBeginEnd = model.EndDate - model.BeginDate;

            if (sequenceBeginEnd < zero)
            {
                return(RedirectToAction("WrongEndBeginDate"));
            }
            foreach (var reserv in ReservationList)
            {
                beginDifference    = reserv.BeginDate - model.BeginDate;
                endDifference      = reserv.EndDate - model.EndDate;
                beginEndDifference = reserv.BeginDate - model.EndDate;
                EndbeginDifference = reserv.EndDate - model.BeginDate;

                if ((beginEndDifference <= zero && endDifference >= zero) ||
                    (endDifference <= zero && EndbeginDifference >= zero) ||
                    (beginEndDifference <= zero && beginDifference >= zero))
                {
                    return(RedirectToAction("EmployeeIsReservedTime"));
                }
            }
            var employeeProjects           = dbOperations.GetEmployeeProjects(_employeeId);
            var noToDoubleProjectEmployees = employeeProjects.Where(s => s.ProjectCode.Replace(" ", string.Empty) == reservation.ProjectCode.Replace(" ", string.Empty)).ToList();

            if (noToDoubleProjectEmployees.Count() == 0)
            {
                modelEmployee.EmployeeId   = _employeeId;
                modelEmployee.ProjectCode  = reservation.ProjectCode;
                modelEmployee.ProjectOwner = false;
                DbOperations.AddProjectEmployeeToDB(modelEmployee);
            }



            DbOperations.AddEmployeeReservationToDB(model);
            return(RedirectToAction("UserList"));
        }
        public ActionResult CreateProject(PROJECTS model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            DbOperations.AddProjectToDB(model);

            var model2 = new PROJECT_EMPLOYEES();

            model2.ProjectCode  = model.ProjectCode;
            model2.ProjectOwner = true;
            model2.EmployeeId   = GetLoggedUserId();
            DbOperations.AddProjectEmployeeToDB(model2);

            return(RedirectToAction("ProjectList"));
        }