-
Notifications
You must be signed in to change notification settings - Fork 0
/
DashboardController.cs
67 lines (56 loc) · 1.97 KB
/
DashboardController.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
using System.Globalization;
using System.Web;
using System.Web.Mvc;
using System.Web.Security;
using MaryKay.Configuration;
namespace myCustomers.Web.Controllers
{
[AuthorizeConsultant]
public class DashboardController : Controller
{
readonly IAppSettings _appSettings;
readonly ISubsidiaryAccessor _subsidiaryAccessor;
public DashboardController(IAppSettings appSettings, ISubsidiaryAccessor subsidiaryAccessor)
{
_appSettings = appSettings;
_subsidiaryAccessor = subsidiaryAccessor;
}
public ActionResult Index()
{
return View();
}
public ActionResult Language(string id)
{
try
{
// validate by trying to construct a cultureinfo class
var language = new CultureInfo(CultureMapper.MapCulture(id, _subsidiaryAccessor.GetSubsidiaryCode()));
// use the unmapped culture value for the cookie for compatibility with InTouch
SetCookie("uiculture", id);
SetCookie("culture", id);
}
catch { }
if (Request.UrlReferrer != null && !string.IsNullOrEmpty(Request.UrlReferrer.AbsolutePath))
return Redirect(Request.UrlReferrer.ToString());
else
return RedirectToAction("Index");
}
string GetCookieDomain()
{
if (Request.Url.Host.Contains("localhost"))
return string.Empty;
return _appSettings.GetValue("CookieDomain");
}
void SetCookie(string name, string value)
{
if (Response.Cookies[name] != null)
Response.Cookies.Remove(name);
var cookie = new HttpCookie(name, value)
{
Path = FormsAuthentication.FormsCookiePath,
Domain = GetCookieDomain(),
};
Response.Cookies.Set(cookie);
}
}
}