Пример #1
0
        public ActionResult PunchClockOut(PunchedClock model)
        {
            var userId = User.Identity.GetUserId();

            model = _clockService.ClockOut(model.Id, DateTime.UtcNow);

            return(RedirectToRoute("Index"));
        }
Пример #2
0
        public PunchedClock ClockIn(string userId, DateTime time)
        {
            var model = new PunchedClock
            {
                ApplicationUserId = userId,
                PunchIn           = time
            };

            _context.PunchedClocks.Add(model);
            _context.SaveChanges();

            return(model);
        }
Пример #3
0
        public ActionResult PunchClock()
        {
            var userId = User.Identity.GetUserId();
            var model  = _clockService.GetClockByUser(userId);

            if (model == null)
            {
                model = new PunchedClock
                {
                    PunchIn = DateTime.MinValue
                };

                ViewData["Message"] = "Clock In";

                return(View(model));
            }

            ViewData["Message"] = "Clock Out";

            return(View(model));
        }