public ActionResult Submit(User fb)
        {
            List <Country> allCountry = new List <Country>();


            using (DiplomskiContext dc = new DiplomskiContext())
            {
                allCountry = dc.Countries.OrderBy(a => a.CountryName).ToList();
                //if( nt != null && nt.Id>0)
                //{

                //}
            }
            ViewBag.Id = new SelectList(allCountry, "Id", "CountryName", fb.Id);

            if (ModelState.IsValid)
            {
                using (DiplomskiContext dc = new DiplomskiContext())
                {
                    dc.Users.Add(fb);
                    dc.SaveChanges();
                    ViewBag.Message = "Successfully submitted";
                }
            }
            else
            {
                ViewBag.Message = "Failed ! Please Try again.";
            }



            return(View(fb));
        }
Пример #2
0
        public ActionResult RegisterUser(User account)
        {
            if (ModelState.IsValid)
            {
                List <Country> allNationalities = new List <Country>();
                using (DiplomskiContext db = new DiplomskiContext())

                {
                    //allNationalities = db.Nationalities.OrderBy(a => a.CountryName).ToList();


                    ViewBag.Departments = new SelectList(db.Departments, "Id", "DepartmentName");

                    account = db.Users.Add(account);
                    db.SaveChanges();

                    //Session["user_id"] = account.Id;
                }

                ModelState.Clear();
                ViewBag.Message = "Successfully Created User Account";
                // ViewBag.Message = account.Firstname + "Successfully registered.";
                return(RedirectToAction("RegisterUser"));
            }

            return(View());
        }
        // GET: DropDown
        public ActionResult Submit()
        {
            List <Country> allCountry = new List <Country>();

            //  List<State> allState = new List<State>();
            using (DiplomskiContext dc = new DiplomskiContext())
            {
                allCountry = dc.Countries.OrderBy(a => a.CountryName).ToList();
            }
            ViewBag.Id = new SelectList(allCountry, "Id", "CountryName");
            //ViewBag.StateID = new SelectList(allState, "StateID", "StateName");
            return(View());
        }