public IActionResult Create(CreateCaseManagerViewModel createCMVM)
        {
            if (ModelState.IsValid)
            {
                CaseManager cm = new CaseManager()
                {
                    LastName    = createCMVM.LastName,
                    FirstName   = createCMVM.FirstName,
                    Email       = createCMVM.Email,
                    PhoneNumber = createCMVM.PhoneNumber,
                    ProgramID   = createCMVM.ProgramID
                };

                _context.Add(cm);
                _context.SaveChanges();

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

            createCMVM.Programs = _context.Programs.Select(p => new SelectListItem()
            {
                Value = p.ID.ToString(), Text = p.Name
            }).ToList();

            return(View(createCMVM));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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));
        }
Ejemplo n.º 4
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));
        }
Ejemplo n.º 5
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));
        }
Ejemplo 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));
        }