示例#1
0
 public IActionResult TeamIndex(Guid TeamId, string TeamName)
 {
     ViewData["Message"]  = "Your Team page.";
     ViewData["TeamName"] = TeamName;
     ViewBag.TeamId       = TeamId;
     return(View(Personrepository.Get(person => person.TeamId == TeamId)));
 }
示例#2
0
/*        [Route("/CreateNewVacation/{personId}")]*/
        public IActionResult CreateNewVacation(Guid personId, VacationTwo vacation)
        {
            Person person = Personrepository.FindById(personId);

            CountVacation countVacation = new CountVacation();
            Vacation      NewVacation   = new Vacation();

            NewVacation.Id         = Guid.NewGuid();
            NewVacation.FirstDate  = DateTime.ParseExact(vacation.startDay, "M/d/yyyy", CultureInfo.InvariantCulture);
            NewVacation.SecontDate = DateTime.ParseExact(vacation.EndDay, "M/d/yyyy", CultureInfo.InvariantCulture);
            if (NewVacation.FirstDate > NewVacation.SecontDate || countVacation.CountDaysVacation(NewVacation.FirstDate, NewVacation.SecontDate) > person.Days)
            {
                return(Redirect("/Home/Workers"));
            }
            NewVacation.Days   = countVacation.CountDaysVacation(NewVacation.FirstDate, NewVacation.SecontDate);
            NewVacation.People = person;

            /* if (person.Days<= NewVacation.Days)
             *   return Redirect("/Workers"); */

            person.Days -= countVacation.CountDaysVacation(NewVacation.FirstDate, NewVacation.SecontDate);

            Vacationrepository.Create(NewVacation);
            return(Redirect("/Home/Workers"));
        }
        /*      [Route("/ShowVacation/{personId}") ]*/
        public IActionResult ShowVacation(Guid personId)
        {
            ViewBag.PersonId = personId;
            ViewBag.person   = Personrepository.FindById(personId);
            IEnumerable <Vacation> vacations = Vacationrepository.IncludeGet(t => t.People).Where(i => i.Peopleid == personId);

            return(View(vacations));
        }
示例#4
0
        public JsonResult GetEvents(Guid TeamId)
        {
            int vacationsCount = Vacationrepository.Count();
            int i                 = 1;
            var colors            = new List <string>();
            int integerRedValue   = 8;
            int integerGreenValue = 95;
            int integerBlueValue  = 52;

            for (int j = 0; j < vacationsCount; j++)
            {
                string hexValue = '#' + integerRedValue.ToString("X2") + integerGreenValue.ToString("X2") + integerBlueValue.ToString("X2");
                colors.Add(hexValue);
                integerBlueValue  += 24;
                integerGreenValue += 14;
                integerRedValue   += 41;
                if (integerBlueValue > 255)
                {
                    integerBlueValue = 0;
                }
                if (integerGreenValue > 255)
                {
                    integerGreenValue = 0;
                }
                if (integerRedValue > 255)
                {
                    integerRedValue = 0;
                }
            }
            var                  events    = new List <CalendarEventy>();
            List <Vacation>      vacations = new List <Vacation>();
            IEnumerable <Person> people    = Personrepository.Get(p => p.TeamId == TeamId).ToList();

            foreach (Person person in people)
            {
                vacations = Vacationrepository.Get(p => p.Peopleid == person.Id).ToList();
                DateTime start;
                DateTime end;
                var      viewModel = new CalendarEventy();
                foreach (Vacation vacation in vacations)
                {
                    start = vacation.FirstDate;
                    end   = vacation.SecontDate;
                    events.Add(new CalendarEventy()
                    {
                        Id              = Guid.NewGuid(),
                        allDay          = true,
                        title           = "Vacation" + " " + person.LastName + " " + person.Name,
                        start           = start.ToString("yyyy-MM-dd"),
                        end             = end.ToString("yyyy-MM-dd"),
                        backgroundColor = colors[i]
                    });
                }
                i++;
            }
            return(Json(events.ToArray()));
        }
示例#5
0
        public IActionResult DeleteVacation(Guid vacationId, Guid personId)
        {
            Vacation vacation = Vacationrepository.FindById(vacationId);
            Person   person   = Personrepository.FindById(personId);

            person.Days += vacation.Days;
            Vacationrepository.Remove(vacation);
            Personrepository.Update(person);
            return(Redirect("/Home/Workers"));
        }
        public IActionResult AddnewVacation(Guid personId)
        {
            IEnumerable <Weekend> weekends = Weekendrepository.Get(p => p.startDate > DateTime.Now);
            Person person = Personrepository.FindById(personId);

            ViewBag.AddDays  = person.Days;
            ViewBag.weekends = weekends;
            ViewBag.PersonId = personId;
            return(View());
        }
示例#7
0
        /*      [Route("/AddnewVacation/{personId}")]*/
        public IActionResult AddnewVacation(Guid personId)
        {
            List <Weekend> weekends = Weekendrepository.Get().ToList();
            Person         person   = Personrepository.FindById(personId);

            ViewBag.AddDays  = person.Days;
            ViewBag.weekends = weekends;
            //ViewBag.AddDay=
            ViewBag.PersonId = personId;
            return(View());
        }
        public IActionResult AddnewVacation(Guid personId, VacationView vacation)
        {
            Person person = Personrepository.IncludeGet(p => p.Team).FirstOrDefault(x => x.Id == personId);

            if (!VacationServices.CreateVacation(personId, vacation))
            {
                ModelState.AddModelError("EndDay", "Please change date");
                ViewBag.AddDays = person.Days;
                List <Weekend> weekends = Weekendrepository.Get(p => p.startDate > DateTime.Now).ToList();
                ViewBag.weekends = weekends;
                ViewBag.PersonId = personId;
                return(View(vacation));
            }
            return(Redirect("/Home/Workers/Home/Workers"));
        }
示例#9
0
        public int ResultCountAddDay(DateTime CountDate, Person person)
        {
            List <Person> IndexDayTwo = Personrepository.Get().ToList();
            int           IndexDay    = person.Days;


            for (int i = 0; i <= IndexDay; i++)
            {
                if (CountDate.DayOfWeek == DayOfWeek.Sunday || CountDate.DayOfWeek == DayOfWeek.Saturday || AuditDate(CountDate))
                {
                    IndexDay++;
                }
                CountDate = CountDate.AddDays(1);
            }


            return(IndexDay);
        }
示例#10
0
        private int CountTeam(string TeamName)
        {
            List <Person> list = Personrepository.Get(i => i.Team.TeamName == TeamName).ToList();

            return(list.Count);
        }