Ejemplo n.º 1
0
        public override void OnResultExecuting(ResultExecutingContext context)
        {
            base.OnResultExecuting(context);
            //Trace.WriteLine("Starting filter");
            //save url, userId from session, etc...


            //create a Userlog for this request
            var request = context.HttpContext.Request;

            UserLog userLog = TrackingCreate.CreateUserLog(request);

            //TrackingDbContext db = new TrackingDbContext();
            MovieDbContext db = new MovieDbContext();

            db.UserLogs.Add(userLog);
            db.SaveChanges();



            //Trace.WriteLine("raw > url > filepath");
            //Trace.WriteLine(context.HttpContext.Request.RawUrl);
            //Trace.WriteLine(context.HttpContext.Request.Url);
            //Trace.WriteLine(context.HttpContext.Request.FilePath);


            context.Controller.ViewBag.filtered = true;

            //write out all headers
            //var headers = context.HttpContext.Request.Headers;
            //string[] keys =
            //    context.HttpContext.Request.Headers.AllKeys;
            //foreach (string key in keys) {
            //    string msg = string.Format("{0} : {1}", key, headers[key]);
            //    Trace.WriteLine(msg);
            //}

            //write out the user agent
            //string userAgent = context.HttpContext.Request.UserAgent;
            //Trace.WriteLine(userAgent);


            //var model = context.Controller.ViewData.Model;
            //if (model.GetType() == typeof(List<NextFlicksMVC4.Controllers.MoviesController.MovieWithGenreViewModel>))
            //{
            //    Trace.WriteLine("List of models");
            //}

            //test for the custom cookie
            //HttpCookie cookie = context.HttpContext.Request.Cookies.Get("TestCookie");
            //if (cookie != null) {
            //    Trace.WriteLine(cookie.Value);
            //}
            //else {
            //    Trace.WriteLine("Cookie does not exist");
            //}

            //Trace.WriteLine("Ending filter");
        }
        // Add method
        // Get
        public ActionResult Create()
        {
            List <Employee> Employees = CreateEmployeeService().GetEmployeeData().ToList();

            ViewBag.EmpId = Employees.Select(o => new SelectListItem()
            {
                Value = o.EmpId.ToString(),
                Text  = o.FullName,
            });
            var model = new TrackingCreate()
            {
                TrackDate = DateTime.Now
            };

            return(View(model));
        }
        public ActionResult Create(TrackingCreate model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            var service = CreateTrackingService();

            if (service.CreateTracking(model))
            {
                if (model.Temperature >= 100.4)
                {
                    TempData["SaveResult2"] = "DO NOT REPORT TO WORK - Contact YOUR Manager - Temperature >= 100.4";
                    return(RedirectToAction("Index"));
                }
                if (model.SymptomAnswer == "Yes")
                {
                    TempData["SaveResult2"] = "DO NOT REPORT TO WORK - Contact YOUR Manager - Need tested for COVID-19";
                    return(RedirectToAction("Index"));
                }
                if (model.ContactAnswer == "Yes")
                {
                    TempData["SaveResult2"] = "DO NOT REPORT TO WORK - Contact YOUR Manager - Need to be put in Quarantine";
                    return(RedirectToAction("Index"));
                }
                if (model.TempAnswer == "No")
                {
                    TempData["SaveResult2"] = "DO NOT REPORT TO WORK - Contact YOUR Manager - Must take your Temperature within 90 mins";
                    return(RedirectToAction("Index"));
                }
                TempData["SaveResult1"] = "You have been APPROVED to work today!";
                return(RedirectToAction("Index"));
            }
            ;

            return(View(model));
        }
        public bool CreateTracking(TrackingCreate model)
        {
            var entity =
                new Tracking()
            {
                TrackingId    = model.TrackingId,
                TrackDate     = DateTime.Now,
                IndividualId  = _userId,
                SymptomAnswer = model.SymptomAnswer,
                ContactAnswer = model.ContactAnswer,
                TempAnswer    = model.TempAnswer,
                Temperature   = model.Temperature,
                MaskAnswer    = model.MaskAnswer,
                GroupAnswer   = model.GroupAnswer,
                EmpId         = model.EmpId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.Trackings.Add(entity);
                return(ctx.SaveChanges() == 1);
            }
        }