public ActionResult Index(CloudUser cloudUser) { if (cloudUser.IsGoodInfo()) { try { using (var context = new StorageBoxContext()) { using (var transaction = context.Database.BeginTransaction()) { try { cloudUser.SetPersonalFolder(); context.Users.Add(cloudUser); context.SaveChanges(); transaction.Commit(); } catch { transaction.Rollback(); } } } } catch (Exception ex) { Debug.WriteLine(ex); } } return(RedirectToAction("Index", "Authorization")); }
public ActionResult Index(CloudUser user) { if (user != null && WS.IsGoodString(user.Login) && WS.IsGoodString(user.Passwords)) { try { using (var context = new StorageBoxContext()) { CloudUser cloudUser = context.Users.FirstOrDefault( x => x.Login.ToLower().Equals(user.Login.ToLower()) && x.Passwords.Equals(user.Passwords)); if (cloudUser != null) { if (WS.IsGoodString(cloudUser.FolderName)) { string basePath = Server.MapPath("~/Upload/PrivateRepository"); if (Directory.Exists(basePath)) { string path = Path.Combine(basePath, cloudUser.FolderName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } Session["currPuth"] = path; Session["rootPuth"] = path; Session["authorized"] = true; } } } } } catch (Exception ex) { Debug.WriteLine(ex); } } return(RedirectToAction("Index", "Home")); }