Exemplo n.º 1
0
        public async Task <IActionResult> Create(CreateFileViewModel createFilevm)
        {
            if (ModelState.IsValid)
            {
                File newFile = new File
                {
                    ConsumerID    = createFilevm.ConsumerID,
                    CaseManagerID = createFilevm.CaseManagerID,
                    RoomID        = createFilevm.RoomID,
                    Quantity      = createFilevm.Quantity
                };

                //if file already exists, ask if user would like to update quantity
                if (_context.FileExists(newFile))
                {
                    File oldFile = _context.Files.First(f => f.CaseManagerID == newFile.CaseManagerID && f.ConsumerID == newFile.ConsumerID && f.RoomID == newFile.RoomID);

                    return(Redirect(String.Format("AddConfirm?id={0}&userNum={1}", oldFile.ID, newFile.Quantity)));
                }
                ;

                _context.Add(newFile);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(createFilevm));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("ID,Name")] Models.Program program)
        {
            if (ModelState.IsValid)
            {
                _context.Add(program);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(program));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("ID,Name,BuildingID")] Room room)
        {
            if (ModelState.IsValid)
            {
                _context.Add(room);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["BuildingID"] = new SelectList(_context.Buildings, "ID", "ID", room.BuildingID);
            return(View(room));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create(CreateBuildingViewModel createBuildingVM)
        {
            if (ModelState.IsValid)
            {
                Building newBuilding = new Building
                {
                    Name        = createBuildingVM.Name,
                    Address     = createBuildingVM.Address,
                    PhoneNumber = createBuildingVM.PhoneNumber
                };

                _context.Add(newBuilding);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Details)));
            }
            return(View(createBuildingVM));
        }
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var caseManager = await _context.CaseManagers.SingleOrDefaultAsync(m => m.ID == id);

            _context.CaseManagers.Remove(caseManager);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create(CreateConsumerViewModel createConsumerVM)
        {
            if (ModelState.IsValid)
            {
                Consumer newConsumer = new Consumer
                {
                    LastName  = createConsumerVM.LastName,
                    FirstName = createConsumerVM.FirstName,
                    DOB       = createConsumerVM.DOB
                };

                _context.Add(newConsumer);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }

            return(View(createConsumerVM));
        }
Exemplo n.º 7
0
        public IActionResult Index()
        {
            //Check if user logged in:
            if (HttpContext.Session.GetString("Username") == null)
            {
                return(Redirect("Login"));
            }

            //Change View based on Role:
            FileMember user = _context.FileMembers.Single(u => u.Email == HttpContext.Session.GetString("Username"));

            ViewBag.Role = user.Role;

            // For Search:
            HomeViewModel homeViewModel = new HomeViewModel();

            // For Daily Tasks:
            homeViewModel.ActionFiles = _context.Files
                                        .Where(f => f.Status == Status.Damaged || f.Status == Status.Full)
                                        .Include(f => f.Consumer)
                                        .Include(f => f.CaseManager)
                                        .Include(f => f.Room)
                                        .OrderBy(f => f.Consumer.LastName);

            homeViewModel.InactiveFiles = _context.Files
                                          .Where(f => f.ShredDate <= homeViewModel.Today)
                                          .Include(f => f.Consumer)
                                          .Include(f => f.CaseManager)
                                          .Include(f => f.Room)
                                          .OrderBy(f => f.Consumer.LastName);

            foreach (File file in homeViewModel.InactiveFiles)
            {
                file.Status = Models.Status.Shred;
                _context.Update(file);
                _context.SaveChangesAsync();
            }

            return(View(homeViewModel));
        }