Пример #1
0
        public ActionResult Create(string command, UserMasterViewModel userMasterViewModel)
        {
            if (command.Equals("Add"))
            {
                UserMaster userMaster = userMasterViewModel.UserMaster;
              
                userMasterViewModel.UserMaster = new UserMaster();
                List<UserMaster> listUserMaster = new List<UserMaster>();
                if (userMasterViewModel.UserMasters != null)
                {
                   listUserMaster = userMasterViewModel.UserMasters.ToList();
                }
               
                listUserMaster.Add(userMaster);

                userMasterViewModel.UserMasters = listUserMaster;


            }
            else if (command.Equals("Create"))
            {
                UserMaster userMaster = new UserMaster();
                if (ModelState.IsValid)
                {
                    db.UserMasters.Add(userMaster);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
                return View(userMaster);
            }
            return View(userMasterViewModel);
        }
Пример #2
0
 // GET: Home/Create
 public ActionResult Create()
 {
     UserMasterViewModel u = new UserMasterViewModel();
     return View(u);
 }