Beispiel #1
0
        public ActionResult Create([Bind(Include = "UserId,UserEmail,Password,Role")] tbl_User tbl_User)
        {
            if (ModelState.IsValid)
            {
                db.tbl_User.Add(tbl_User);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(tbl_User));
        }
Beispiel #2
0
        public ActionResult Register(UserModel objUserModel)
        {
            if (ModelState.IsValid)
            {
                if (!objUserDbEntities.Users.Any(m => m.Email == objUserModel.Email))
                {
                    User objUser = new DBModel.User();
                    objUser.CreatedOn = DateTime.Now;
                    objUser.FirstName = objUserModel.FirstName;
                    objUser.LastName  = objUserModel.LasttName;
                    objUser.Email     = objUserModel.Email;
                    objUser.Password  = objUserModel.Password;

                    objUserDbEntities.Users.Add(objUser);
                    objUserModel = new UserModel();
                    objUserDbEntities.SaveChanges();

                    // objUserModel.Message = "User is successfully Added";
                    ViewBag.Message = "User is successfully Added";
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ModelState.AddModelError("Error", "Email Already exits");
                    return(View());
                }
            }

            return(View());
        }
        public ActionResult Register(User U)
        {
            if (ModelState.IsValid)
            {
                if (db.Users.Where(x => x.Username == U.Username).FirstOrDefault() == null)
                {
                    db.Users.Add(U);
                    db.SaveChanges();
                    // ModelState.Clear();
                    // U = null;
                    ViewBag.Message = "Successfully registered";
                    return(RedirectToAction("Login", "User"));
                }
                ViewBag.Message = "User already registered, please choose enter username";
            }

            return(View());
        }
        public ActionResult Create([Bind(Include = "TaskID,TaskDescription,StartDate,FinishDate,Category,UserID")] Task task)
        {
            if (Session["LogedUserID"] == null)
            {
                return(RedirectToAction("Index"));
            }

            if (ModelState.IsValid)
            {
                task.UserID = Int32.Parse(Session["LogedUserID"].ToString());


                db.Tasks.Add(task);
                db.SaveChanges();
                ViewBag.Message = "tasks";
                return(RedirectToAction("Index"));
            }

            // ViewBag.UserID = Int32.Parse(Session["LogedUserID"].ToString());
            return(View(task));
        }
 public ActionResult Index(User user)
 {
     if (ModelState.IsValid)
     {
         UserDbEntities db = new UserDbEntities();
         db.Users.AddObject(user);
         db.SaveChanges();
         return(View("Success"));
     }
     else
     {
         return(View("Index", user));
     }
 }
Beispiel #6
0
 public static APP_USER Add(APP_USER oModel)
 {
     try
     {
         using (UserDbEntities oContext = new UserDbEntities())
         {
             oContext.APP_USER.Add(oModel);
             oContext.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception("erreur", ex);
     }
     return(oModel);
 }
Beispiel #7
0
        public static List <APP_USER> Delete(int oId)
        {
            APP_USER oModel = new APP_USER();

            try
            {
                using (UserDbEntities oContext = new UserDbEntities())
                {
                    oModel = oContext.APP_USER.Find(oId);
                    oContext.APP_USER.Remove(oModel);
                    oContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("erreur", ex);
            }

            return(SelectUser());
        }
Beispiel #8
0
        public static APP_USER Update(APP_USER oModel, int ID)
        {
            try
            {
                using (UserDbEntities oContext = new UserDbEntities())
                {
                    APP_USER userInDb = new APP_USER();
                    userInDb           = oContext.APP_USER.Find(ID);
                    userInDb.FIRSTNAME = oModel.FIRSTNAME;
                    userInDb.LASTNAME  = oModel.LASTNAME;
                    userInDb.BIRTHDATE = oModel.BIRTHDATE;
                    userInDb.HEIGHT    = oModel.HEIGHT;
                    oContext.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("erreur", ex);
            }

            return(oModel);
        }