Exemplo n.º 1
0
        // GET: Pace
        public ActionResult Index()
        {
            PaceModel objPaceModel = new PaceModel();

            objPaceModel = CalculatePace();
            return(View(objPaceModel));
        }
Exemplo n.º 2
0
        public void TestGetWeekStartEnd()
        {
            PaceController objPaceController = new PaceController(proxy);
            DateTime       sdate             = DateTime.Now;
            DateTime       eDate             = DateTime.Now;
            PaceModel      objPaceModel      = objPaceController.CalculatePace();

            eDate = objPaceController.GetWeekStartEnd(DateTime.Now, out sdate);
        }
Exemplo n.º 3
0
        private PaceModel CalculatePace()
        {
            PaceModel objPaceModel = new PaceModel();

            DateTime eDateSwp = DateTime.Now;
            DateTime sDateSwp = GetPreviousDate(DateTime.Now.DayOfWeek, out eDateSwp);

            DateTime eDateVac = DateTime.Now;
            DateTime sDateVac = GetUpcomingDate(DateTime.Now.DayOfWeek, out eDateVac);

            if (HasLeave(DateTime.Now))
            {
            }

            return(objPaceModel);
        }
Exemplo n.º 4
0
        public PaceModel CalculatePace()
        {
            PaceModel objPaceModel = new PaceModel();
            DateTime  currDate     = new DateTime(2015, 08, 26);
            DateTime  eDateSwp     = DateTime.Now;
            DateTime  sDateSwp     = GetPreviousDate(currDate.DayOfWeek, currDate, out eDateSwp);

            DateTime        eDateVac       = DateTime.Now;
            DateTime        sDateVac       = GetUpcomingDate(currDate.DayOfWeek, currDate, out eDateVac);
            PaceData        objPaceDataDAL = new PaceData();
            List <Vacation> lstVacation    = _proxy.GetVacationData();
            List <Swipe>    lstSwipe       = objPaceDataDAL.GetSwipeData();
            List <DateTime> vacationDates  = new List <DateTime>();

            lstVacation = lstVacation.Where(vac => vac.FromDate <= eDateVac && vac.ToDate >= sDateVac).ToList();
            if (lstVacation.Count() > 0)
            {
                DateTime vacStart = lstVacation.Where(vac => vac.FromDate <= vac.FromDate).First().FromDate;
                DateTime vacEnd   = lstVacation.Where(vac => vac.ToDate >= vac.ToDate).Last().ToDate;
                vacationDates = GetVacationDates(vacStart, vacEnd);
            }

            lstSwipe = lstSwipe.Where(vac => vac.SwipeDate >= sDateSwp && vac.SwipeDate <= eDateSwp).ToList();

            List <DateTime> lstDates = lstSwipe.GroupBy(a => a.SwipeDate).Select(b => b.First().SwipeDate).ToList();

            List <SwipeHours> swipes = new List <SwipeHours>();



            foreach (DateTime date in lstDates)
            {
                foreach (Swipe sp in lstSwipe.Where(a => a.SwipeDate == date).ToList())
                {
                    SwipeHours spHr = swipes.Where(b => b.Date == sp.SwipeDate).FirstOrDefault();
                    if (spHr != null)
                    {
                        if (sp.In < sp.Out)
                        {
                            double hrs = (sp.Out - sp.In).TotalHours;
                            spHr.Hours = spHr.Hours + Convert.ToInt32(hrs);
                            swipes.Remove(spHr);
                            swipes.Add(spHr);
                        }
                    }
                    else
                    {
                        if (sp.In < sp.Out)
                        {
                            double hrs = (sp.Out - sp.In).TotalHours;
                            spHr       = new SwipeHours();
                            spHr.Hours = Convert.ToInt32(hrs);
                            spHr.Date  = sp.SwipeDate;
                            swipes.Add(spHr);
                        }
                    }
                    lstSwipe.Remove(sp);
                }
            }
            DateTime weekSt = currDate;

            DateTime weekEn = GetWeekStartEnd(currDate, out weekSt);

            objPaceModel.SwipeHr    = new List <SwipeHours>();
            objPaceModel.VacationHr = new List <SwipeHours>();
            objPaceModel.OtherHr    = new List <SwipeHours>();
            foreach (DateTime weekDts in GetVacationDates(weekSt, weekEn))
            {
                SwipeHours objSwipeHours = swipes.Where(a => a.Date == weekDts).FirstOrDefault();
                SwipeHours objVacHours;
                SwipeHours objOthr = new SwipeHours();
                if (objSwipeHours == null)
                {
                    objSwipeHours       = new SwipeHours();
                    objSwipeHours.Date  = weekDts;
                    objSwipeHours.Hours = 0;
                }

                if (weekDts.DayOfWeek == DayOfWeek.Friday)
                {
                    objSwipeHours       = new SwipeHours();
                    objSwipeHours.Date  = weekDts;
                    objSwipeHours.Hours = 5;
                    objOthr.Hours       = 4;
                }
                objPaceModel.SwipeHr.Add(objSwipeHours);

                if (vacationDates.Any(a => a == weekDts))
                {
                    objVacHours       = new SwipeHours();
                    objVacHours.Date  = weekDts;
                    objVacHours.Hours = 8;
                }
                else
                {
                    objVacHours       = new SwipeHours();
                    objVacHours.Date  = weekDts;
                    objVacHours.Hours = 0;
                }
                objPaceModel.VacationHr.Add(objVacHours);
                objOthr.Date = weekDts;
                objPaceModel.OtherHr.Add(objOthr);
            }



            ////foreach (DateTime dtm in lstDates)
            ////{
            ////    if (!swipes.Any(a => a.Date == dtm))
            ////        swipes.Add(new SwipeHours { Date = dtm, Hours = 8 });
            ////}

            ////objPaceModel.SwipeHr = swipes;

            return(objPaceModel);
        }
Exemplo n.º 5
0
 public void TestCalculatePace()
 {
     PaceController objPaceController = new PaceController(proxy);
     PaceModel      objPaceModel      = objPaceController.CalculatePace();
 }