예제 #1
0
        public IActionResult Add(AddBillerViewModel addBillerViewModel)
        {
            if (ModelState.IsValid)
            {
                Biller newBiller = new Biller
                {
                    Name  = addBillerViewModel.Name,
                    Phone = addBillerViewModel.Phone,
                    Email = addBillerViewModel.Email,
                    Web   = addBillerViewModel.Web
                };

                //creates model in database
                context.Billers.Add(newBiller);
                //commits changes to db
                context.SaveChanges();

                return(Redirect("/Biller"));
            }
            return(View(addBillerViewModel));
        }
예제 #2
0
        public IActionResult Add(AddAgentViewModel addAgentViewModel)
        {
            if (ModelState.IsValid)
            {
                Agent newAgent = new Agent
                {
                    Name    = addAgentViewModel.Name,
                    Phone   = addAgentViewModel.Phone,
                    Street1 = addAgentViewModel.Street1,
                    Street2 = addAgentViewModel.Street2,
                    City    = addAgentViewModel.City,
                    State   = addAgentViewModel.State,
                    Zip     = addAgentViewModel.Zip
                };

                context.Agents.Add(newAgent);
                context.SaveChanges();

                return(Redirect("/Agent"));
            }
            return(View(addAgentViewModel));
        }