Example #1
0
        public async Task<ActionResult> GetCameraTypes(CameraViewModel model)
        {

            var LoggedInUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            if (!LoggedInUser.Approved)
                return RedirectToAction("Index", "Manage");

            if (ModelState.IsValid)
            {
                model.GetCameraTypesViewModel = new GetCameraTypesViewModel();
                model.GetCameraTypesViewModel.CameraTypes = new List<CameraType>();
                model.GetCameraTypesViewModel.CameraTypes = FujiRepository.GetActiveCameraTypes();

                return View(model);
            }

            return View();
        }
Example #2
0
        public async Task<ActionResult> AddCamera(CameraViewModel model)
        {
            

            if (ModelState.IsValid)
            {
                var LoggedInUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                if (!LoggedInUser.Approved)
                    return RedirectToAction("Index", "Manage");


                var cam = new Camera() { CameraName = model.AddCameraViewModel.CameraName, CameraSerialNumber = model.AddCameraViewModel.CameraSerialNumber, CameraRecipeNumber = model.AddCameraViewModel.CameraRecipeNumber, User = LoggedInUser, Date = DateTime.Now };
                FujiRepository.AddCamera(LoggedInUser, cam);
                FujiRepository.ReCalculatePoints(LoggedInUser);

            }


            return RedirectToAction("Index");
        }
Example #3
0
        public async Task<ActionResult> GetCameras(CameraViewModel model)
        {
            var LoggedInUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

            if (!LoggedInUser.Approved)
                return RedirectToAction("Index", "Manage");

            model.GetCamerasViewModel = new GetCamerasViewModel();
            model.GetCamerasViewModel.Cameras = new List<Camera>();
            model.GetCamerasViewModel.Cameras = FujiRepository.GetUserCamera(User.Identity.GetUserId());
            model.GetCameraTypesViewModel = new GetCameraTypesViewModel();
            model.GetCameraTypesViewModel.CameraTypes = new List<CameraType>();
            model.GetCameraTypesViewModel.CameraTypes = FujiRepository.GetActiveCameraTypes();

            var isAdmin = await UserManager.IsInRoleAsync(User.Identity.GetUserId(), "Admin");

            if (isAdmin)
            {
                model.GetCamerasViewModel.Cameras = FujiRepository.GetAllCameras();
            }
            return View(model);
        }
Example #4
0
        public async Task<ActionResult> AddCameraType(CameraViewModel model)
        {

            if (ModelState.IsValid)
            {
                var LoggedInUser = await UserManager.FindByIdAsync(User.Identity.GetUserId());

                if (!LoggedInUser.Approved)
                    return RedirectToAction("Index", "Manage");

                FujiRepository.AddCameraType(LoggedInUser, model);
                return RedirectToAction("AddCameraType");
            }

            return View(model);

        }
Example #5
0
 internal void AddCameraType(ApplicationUser user, CameraViewModel model)
 {
     var context = HttpContext.Current.GetOwinContext().Get<ApplicationDbContext>();
     var cam = new CameraType() { CameraTypeName = model.AddCameraTypesViewModel.CameraTypeName, CameraTypePoints = Convert.ToInt32(model.AddCameraTypesViewModel.CameraTypePoints), CameraActive = true, User = user };
     context.CameraTypes.Add(cam);
     context.SaveChanges();
 }