public static void Tenancy(this HttpResponseBase response, Tenancy tenancy) { // serialize model to json var json = JsonConvert.SerializeObject(tenancy); // create a cookie var cookie = new HttpCookie(CookieName, json) { Expires = DateTime.UtcNow.AddDays(60), }; // write the cookie response.SetCookie(cookie); }
public virtual ActionResult Institution(int institutionId) { var establishment = _queryProcessor.Execute(new EstablishmentById(institutionId)); if (establishment != null) { var tenancy = new Tenancy { StyleDomain = establishment.WebsiteUrl.GetUrlDomain(), TenantId = institutionId }; Response.Tenancy(tenancy); } return RedirectToAction(MVC.FacultyStaff.Index()); }
public virtual ActionResult SignOut(string returnUrl) { // if user is signed on, sign out and redirect back to this action if (!string.IsNullOrWhiteSpace(User.Identity.Name)) { _userSigner.SignOff(); // reset tenancy cookie var oldTenancy = Request.Tenancy(); var newTenancy = new Tenancy(); if (oldTenancy != null) newTenancy.StyleDomain = oldTenancy.StyleDomain; Response.Tenancy(newTenancy); TempData.Flash("You have successfully been signed out of UCosmic."); return RedirectToAction(MVC.Identity.SignOut(returnUrl)); } return View(); }