Ejemplo n.º 1
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                user.IsActive = true;

                string stUserID = user.UserId.ToString();
                string stPassword = "******";
                if (stUserID.Length >= 3)
                    stPassword += stUserID.Substring(stUserID.Length - 3, 3);

                user.Password = stPassword;
                user.Roles.Add(db.Roles.Find((int)ENRole.Member));
                db.Users.Add(user);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.MohallaId = new SelectList(db.Regions.Where(c => c.RegionTypeId == (int)ENRegionType.Mohalla).Include(u => u.Region1), "RegionId", "RegionNameShow", user.MohallaId);
            return View(user);
        }
Ejemplo n.º 2
0
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.MohallaId = new SelectList(db.Regions.Where(c => c.RegionTypeId == (int)ENRegionType.Mohalla).Include(u => u.Region1), "RegionId", "RegionNameShow", user.MohallaId);
     return View(user);
 }
Ejemplo n.º 3
0
        public ActionResult UserRegister(User model)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(model);
                db.SaveChanges();
            }

            return View(model);
        }