public ActionResult Create_WorkSpace(ProjectName project, string Input) { LoginEntities2 Workspace = new LoginEntities2(); project.UserName = Session["UserName"].ToString(); project.ProjectName1 = Input; Workspace.ProjectNames.Add(project); try { Workspace.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } return(View("WorkSpaces")); }
public ActionResult CreateAccount(login accviewmodel) { LoginEntities2 Login = new LoginEntities2(); Login.logins.Add(accviewmodel); try { Login.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { string message = string.Format("{0}:{1}", validationErrors.Entry.Entity.ToString(), validationError.ErrorMessage); // raise a new exception nesting // the current instance as InnerException raise = new InvalidOperationException(message, raise); } } throw raise; } return(View("Login")); }
// GET: WorkSpace public ActionResult WorkSpaces() { LoginEntities2 DisplayProjects = new LoginEntities2(); String Username = Session["UserName"].ToString(); ViewBag.Name = Username; var list = DisplayProjects.ProjectNames.Where(m => m.UserName == Username).ToList(); return(View(list)); }
public ActionResult Login(login avm) { LoginEntities2 login = new LoginEntities2(); var Signin = login.logins.Where(m => m.username == avm.username && m.password == avm.password).FirstOrDefault(); if (Signin != null) { Session["UserName"] = avm.username; return(RedirectToAction("WorkSpaces", "WorkSpace")); } return(View()); }
public ActionResult Autherrize(MVCLogin.Models.User userModel) { using (LoginEntities2 db = new LoginEntities2()) { var userDetails = db.Users.Where(x => x.UserName == userModel.UserName && x.Password == userModel.Password).FirstOrDefault(); if (userDetails == null) { userModel.LoginErrorMessage = "Wrong username or password."; return(View("Index", userModel)); } else { Session["userID"] = userDetails.UserID; Session["userName"] = userDetails.UserName; return(RedirectToAction("Index", "Home")); } } }