Beispiel #1
0
        public ActionResult Create([Bind(Include = "Id,Name,Email,Password,Addon")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
Beispiel #2
0
        public ActionResult Create([Bind(Include = "Id,Name,Value,ExpirationDate,Type,Environment,Comments,LastNotifiedDate,Application,PIDName")] ViblyyKeyy key)
        {
            if (ModelState.IsValid)
            {
                db.ViblyyKeyies.Add(key);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(key));
        }
Beispiel #3
0
        public ActionResult AddImage(MainPageModel mainModel, HttpPostedFileBase file)
        {
            //salvam imaginea in baza de date
            Stock stockmodel = new Stock();
            User  userModel  = new User();

            using (ProductDataBaseEntities db = new ProductDataBaseEntities())
            {
                stockmodel.ProductCollection = db.Products.ToList <Product>();
            }
            mainModel.stock = stockmodel;

            using (LoginDataBaseEntities db = new LoginDataBaseEntities())
            {
                mainModel.user = db.Users.Where(x => x.UserID == mainModel.user.UserID).FirstOrDefault();
            }

            mainModel.user.ConfirmPassword = mainModel.user.Password;
            string fileName  = Path.GetFileNameWithoutExtension(file.FileName);
            string extension = Path.GetExtension(file.FileName);

            fileName = fileName + DateTime.Now.ToString("yymmssfff") + mainModel.user.UserName.ToString() + extension;
            mainModel.user.ImagePath = "~/Image/" + fileName;
            fileName = Path.Combine(Server.MapPath("~/Image/"), fileName);
            file.SaveAs(fileName);
            // pana aici se salveaza in fisier, mai trebuie modificat in baza de date
            using (LoginDataBaseEntities db = new LoginDataBaseEntities())
            {
                db.Entry(mainModel.user).State = EntityState.Modified;
                db.SaveChanges();
            }
            ModelState.Clear();
            Session["ImagePath"] = mainModel.user.ImagePath;
            return(View("Index", mainModel));
        }
Beispiel #4
0
 public ActionResult AddOrEdit(User userModel)
 {
     using (LoginDataBaseEntities db = new LoginDataBaseEntities())
     {
         userModel.ImagePath = "~/Image/logindefault.jpg";
         if (db.Users.Any(x => x.UserName == userModel.UserName))
         {
             ViewBag.DublicateMessage = "Username already exist!";
             return(View("AddOrEdit", userModel));
         }
         db.Users.Add(userModel);
         db.SaveChanges();
     }
     ModelState.Clear();
     ViewBag.SuccessMessage = "Registration Successful.";
     return(View("AddOrEdit", new User()));
 }
Beispiel #5
0
        public ActionResult AddOrEdit(User userModel)
        {
            using (LoginDataBaseEntities l1 = new LoginDataBaseEntities())
            {
                if (l1.Users.Any(x => x.UserName == userModel.UserName))
                {
                    ViewBag.DuplicateMessage = "User Name already exist";
                    return(View("AddOrEdit", userModel));
                }

                l1.Users.Add(userModel);
                l1.SaveChanges();
            }
            ModelState.Clear();
            ViewBag.SuccessMessage = "Registration Successful";
            return(View("AddOrEdit", new User()));
        }
Beispiel #6
0
        public ActionResult Create(note _notes)
        {
            try
            {
                note nt = new note();
                nt.noteName    = _notes.noteName;
                nt.description = _notes.description;
                user userContext = (user)Session["UserContext"];
                nt.usrId = userContext.userId;

                dbObj.notes.Add(nt);
                dbObj.SaveChanges();

                return(RedirectToAction("GetNotes"));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #7
0
        public ActionResult NewEntry(MVCLogin.Models.User userModel)
        {
            using (LoginDataBaseEntities db = new LoginDataBaseEntities())
            {
                var userDetails = db.Users.Where(x => x.UserName == userModel.UserName).FirstOrDefault();
                if (userDetails != null)
                {
                    userModel.LoginErrorMessage = "Username Already Taken!";
                    return(View("Create", userModel));
                }
                else
                {
                    User user = new User();
                    user.UserName = userModel.UserName;
                    user.Password = userModel.Password;

                    db.Users.Add(user);
                    db.SaveChanges();

                    int latestId = user.UserID;
                    return(RedirectToAction("Index"));
                }
            }
        }