public override string[] GetRolesForUser(string username) { //TODO: add caching List <string> roles = new List <string>(); Db.Client client = (from item in db.Clients where item.Email.Equals(username) select item).FirstOrDefault(); if (client != null) { if (client.ClientType.Level >= 1) { roles.Add("free"); } if (client.ClientType.Level >= 5) { roles.Add("basic"); } if (client.ClientType.Level >= 10) { roles.Add("extended"); } if (client.ClientType.Level >= 100) { roles.Add("admin"); } } return(roles.ToArray()); }
public ActionResult Client(Db.Client model) { Db.Client client = new Db.Client(); using (var db = new Db.TipTraceEntities()) { if (ModelState.IsValid) { client = (from item in db.Clients where item.ClientId.Equals(model.ClientId) select item).FirstOrDefault(); client.TypeId = model.TypeId; db.SaveChanges(); var ClientTypeList = (from d in db.ClientTypes orderby d.Level select d).ToList(); ViewBag.ClientTypeList = new SelectList(ClientTypeList, "ClientTypeId", "Name", client.TypeId); ViewData["Message"] = "Saved"; } } return(View(client)); }
//public bool EmailIsValidated { get; set; } public override bool ValidateUser(string email, string password) { Db.Client client = (from item in db.Clients where item.Email.Equals(email) && item.Password.Equals(password) select item).FirstOrDefault(); if (client != null) { //EmailIsValidated = client.IsValidated; return(true); } return(false); }
public ActionResult CustomEmail(Models.Settings model) { if (ModelState.IsValid) { Db.Client client = (from item in db.Clients where item.ClientId.Equals(CurrentClient.ClientId) select item).FirstOrDefault(); client.CustomEmailTemplate = model.CustomEmailTemplate; db.SaveChanges(); ViewData["Message"] = "Saved"; } return(View(model)); }
public ActionResult Design(Models.Settings model) { if (ModelState.IsValid) { Db.Client client = (from item in db.Clients where item.ClientId.Equals(CurrentClient.ClientId) select item).FirstOrDefault(); client.CustomColor1 = model.CustomColor1; client.CustomColor2 = model.CustomColor2; client.CustomColor3 = model.CustomColor3; client.CustomColor4 = model.CustomColor4; client.CustomStatus1 = model.CustomStatus1; db.SaveChanges(); ViewData["Message"] = "Saved"; } return(View(model)); }
public ActionResult Manage(Models.PersonalModel model) { using (var db = new Db.TipTraceEntities()) { if (ModelState.IsValid) { Db.Client client = (from item in db.Clients where item.ClientId.Equals(CurrentClient.ClientId) select item).FirstOrDefault(); client.Name = model.Name; client.WebsiteUrl = model.Url; db.SaveChanges(); ViewData["Message"] = "Saved"; } } return(View(model)); }
private static Client ConstructClient(Db.Client dbClient) { return(new Client { Guid = dbClient.Guid, FirstName = dbClient.FirstName, LastName = dbClient.LastName, Patronymic = dbClient.Patronymic, Birthday = dbClient.Birthday, Phone = dbClient.Phone, Email = dbClient.Email, Password = dbClient.Password, Sex = dbClient.Sex, PassportNumber = dbClient.PassportNumber, PassportSeries = dbClient.PassportSeries, BankCard = dbClient.BankCard, Login = dbClient.Login, ImagePath = System.IO.Path.Combine(Settings.AttachedFiles ?? "", dbClient.ImagePath) }); }
public ActionResult Validate(string id) { using (var db = new Db.TipTraceEntities()) { Db.Client client = (from item in db.Clients where item.ValidateHash.Equals(id) select item).FirstOrDefault(); if (client == null) { //verkeerde code, niks doen, maar wel melding geven ViewData["ErrorMessage"] = "Message"; } else { //goede code, updaten client.IsValidated = true; client.DateEdited = DateTime.Now; db.SaveChanges(); } } return(View()); }
public ActionResult Index() { string Url = string.Empty; string ClientHash = string.Empty; Db.Client client = null; //Client Settings bool clientWithEmailReward = false; bool clientWithEmailUpdate = false; string DefaultTipMessage = ""; string clientColor1 = ""; string clientColor2 = ""; string clientColor3 = ""; string clientColor4 = ""; bool clientStatus1 = false; int clientId = 0; if (!string.IsNullOrEmpty(Request.QueryString["url"])) { Url = Request.QueryString["url"].ToString(); } if (!string.IsNullOrEmpty(Request.QueryString["cid"])) { ClientHash = Request.QueryString["cid"].ToString(); } if (!string.IsNullOrEmpty(ClientHash)) { client = (from item in db.Clients where item.Hash == ClientHash select item).FirstOrDefault(); } //test client //client = (from item in db.Clients where item.ClientId == 10 select item).FirstOrDefault(); ViewBag.Url = Url; ViewBag.ClientHash = ClientHash; if (client != null) { if (client.ClientType.Level >= 5) //Basic { clientWithEmailReward = client.WithEmailReward; clientWithEmailUpdate = client.WithEmailUpdate; clientColor1 = client.CustomColor1; clientColor2 = client.CustomColor2; clientColor3 = client.CustomColor3; clientColor4 = client.CustomColor4; clientStatus1 = client.CustomStatus1; clientId = client.ClientId; if (!string.IsNullOrEmpty(client.DefaultTipMessage)) { DefaultTipMessage = client.DefaultTipMessage; } } } ViewBag.ClientId = clientId; ViewBag.ClientSettings_WithEmailReward = clientWithEmailReward.ToString().ToLower(); ViewBag.ClientSettings_WithEmailUpdate = clientWithEmailUpdate.ToString().ToLower(); ViewBag.ClientSettings_DefaultTipMessage = DefaultTipMessage; ViewBag.ClientSettings_Color1 = clientColor1; ViewBag.ClientSettings_Color2 = clientColor2; ViewBag.ClientSettings_Color3 = clientColor3; ViewBag.ClientSettings_Color4 = clientColor4; ViewBag.ClientSettings_Status1 = clientStatus1; return(View(new Web.Models.Share())); }
public ActionResult Index(String Url) { if (string.IsNullOrEmpty(Url)) { return(HttpNotFound()); } string ClientHash = string.Empty; Db.Client client = null; int? clientid = null; if (!string.IsNullOrEmpty(Request.QueryString["cid"])) { ClientHash = Request.QueryString["cid"].ToString(); } if (!string.IsNullOrEmpty(ClientHash)) { client = (from item in db.Clients where item.Hash == ClientHash select item).FirstOrDefault(); } if (client != null) { clientid = client.ClientId; } //check the database for the url Db.Url CheckUrl = db.GetUrlByValue(Url, clientid).FirstOrDefault(); //(from item in db.Urls where item.Value.Equals(Url) select item).FirstOrDefault(); bool UpdateUrl = false; if (CheckUrl != null) { UpdateUrl = CheckUrl.DateUpdated <= DateTime.Now.AddDays(-7); } if (CheckUrl == null || UpdateUrl) { if (!UpdateUrl) { CheckUrl = new Db.Url(); } //get the site..& parse the content Utility.UrlInfo UrlInfo = Utility.ParseUrl.getUrlInfo(Url); CheckUrl.Value = UrlInfo.URL; CheckUrl.Title = UrlInfo.Title; CheckUrl.Description = UrlInfo.Description; CheckUrl.DateUpdated = DateTime.Now; //save the content if (!UpdateUrl) { CheckUrl.ViewCount = 1; CheckUrl.DateAdded = DateTime.Now; Db.UrlView FirstView = new Db.UrlView(); FirstView.DateAdded = DateTime.Now; FirstView.ClientId = clientid; CheckUrl.UrlViews.Add(FirstView); db.Urls.AddObject(CheckUrl); } db.SaveChanges(); } Models.Url output = new Models.Url(); output.Id = CheckUrl.UrlId; output.Value = CheckUrl.Value; output.Title = HttpUtility.HtmlDecode(CheckUrl.Title); //wellicht deze regel alleen bij sharen van linkedin? output.Description = HttpUtility.HtmlDecode(CheckUrl.Description); //System.Threading.Thread.Sleep(1000); //output the correct return(Json(output, JsonRequestBehavior.AllowGet)); }