public ActionResult Edit(int?id)
        {
            var currentUser = User.Identity.GetUserId();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClassSignUp classSignUp = db.ClassSignUps.Find(id);

            if (classSignUp == null)
            {
                return(HttpNotFound());
            }
            if (User.IsInRole("Customer"))
            {
                ViewBag.UserID = new SelectList(db.AspNetUsers.Where(x => x.Id == currentUser), "Id", "FullName", classSignUp.UserID);
            }
            else
            {
                ViewBag.UserID = new SelectList(db.AspNetUsers, "Id", "FullName", classSignUp.UserID);
            }
            ViewBag.ClassDateID = new SelectList(db.ClassDates, "ClassDateID", "NameDate", classSignUp.ClassDateID);
            return(View(classSignUp));
        }
Exemplo n.º 2
0
        public ActionResult SignUp(ClassSignUp SignUp)
        {
            ComputerShopEntities data = new ComputerShopEntities();


            int a = data.Users.Where(x => x.UserName.Equals(SignUp.userName)).Count();

            if (a == 0)
            {
                User user = new User();

                user.UserName = SignUp.userName;
                user.PassWord = SignUp.passWord;
                user.Address  = SignUp.address;
                user.Phone    = SignUp.Phone;
                user.role     = "Member";
                if (SignUp.rePassWord != SignUp.passWord)
                {
                    ViewBag.a = "Mật Khẩu và Nhập Lại Mật Khẩu Không Đúng";
                    return(View());
                }
                else
                {
                    ViewBag.a = "Đăng kí thành công";
                    data.Users.Add(user);
                    data.SaveChanges();
                    return(View());
                }
            }
            else
            {
                ViewBag.b = "Tên đăng nhập đã tồn tại";
                return(View());
            }
        }
        public ActionResult DeleteConfirmed(int id)
        {
            ClassSignUp classSignUp = db.ClassSignUps.Find(id);

            db.ClassSignUps.Remove(classSignUp);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ClassSignUp classSignUp = db.ClassSignUps.Find(id);

            if (classSignUp == null)
            {
                return(HttpNotFound());
            }
            return(View(classSignUp));
        }
        public ActionResult Create([Bind(Include = "ClassSignUpID,UserID,ClassDateID")] ClassSignUp classSignUp)
        {
            var currentUser = User.Identity.GetUserId();

            if (ModelState.IsValid)
            {
                db.ClassSignUps.Add(classSignUp);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            if (User.IsInRole("Customer"))
            {
                ViewBag.UserID = new SelectList(db.AspNetUsers.Where(x => x.Id == currentUser), "Id", "FullName", classSignUp.UserID);
            }
            else
            {
                ViewBag.UserID = new SelectList(db.AspNetUsers, "Id", "FullName", classSignUp.UserID);
            }
            ViewBag.ClassDateID = new SelectList(db.ClassDates, "ClassDateID", "NameDate", classSignUp.ClassDateID);
            return(View(classSignUp));
        }