// GET: ProfileRole public ActionResult Index() { SqlHelper.DbContext(); LayoutViewModel layoutViewModel = new LayoutViewModel(); var userId = Session["UserId"].ToString(); Users user = SqlHelper.GetUser(userId); HttpCookie cookie = FormsAuthentication.GetAuthCookie(user.UserName, true); var ticket = FormsAuthentication.Decrypt(cookie.Value); FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1, //version ticket.Name, DateTime.Now, //creation DateTime.Now.AddMinutes(60), //Expiration true, ""); // Encrypt the ticket. string encTicket = FormsAuthentication.Encrypt(authTicket); // Create the cookie. Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)); return(View(layoutViewModel.LayoutViewModelProfileRolesBuilder(Session["UserId"].ToString()))); }
public ActionResult Create(FormCollection collection) { var userId = Session["UserId"].ToString(); SqlHelper.DbContext(); string id = Guid.NewGuid().ToString(); string profileId = collection["Profiles"]; Profiles profileName = SqlHelper.GetProfile(profileId); string roleId = collection["Roles"]; Roles roleName = SqlHelper.GetRole(roleId); if (ModelState.IsValid) { SqlHelper.CreateProfileRole(id, profileId, profileName.name, roleId, roleName.name); return(RedirectToAction("Index")); } return(View(layoutViewModel.LayoutViewModelProfileRolesBuilder(Session["UserId"].ToString()))); }