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 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 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)); }
public ActionResult Parameter(Models.AdminSettings model) { using (var db = new Db.TipTraceEntities()) { if (ModelState.IsValid) { Db.Setting setting = (from item in db.Settings where item.SettingId.Equals(model.SettingId) select item).FirstOrDefault(); setting.Name = model.Name; setting.Value = model.Value; db.SaveChanges(); ViewData["Message"] = "Saved"; } } return(View(model)); }
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(Web.Models.Share share) { bool WithFacebookShare = false; string Response = string.Empty; //process the Userhash if email is send string EmailIdentifier = share.ManualEmail; string EmailName = share.ManualName; if (!string.IsNullOrEmpty(EmailIdentifier) && !string.IsNullOrEmpty(EmailName)) { Db.User EmailUser = db.ProcessToken(this.UserHash, 6, EmailIdentifier, EmailName, EmailIdentifier, string.Empty, string.Empty, string.Empty).FirstOrDefault(); this.UserHash = EmailUser.Hash; } //Save the session, and get the sharesessionId int?ShareSessionId = db.SaveShareSession(this.UserHash, share.Url.Id, share.ClientHash, share.Message).FirstOrDefault(); int ShareCounter = 0; List <string> UrlCodes = db.GetUniqueUrlCodes(share.Targets.Count()).ToList(); if (ShareSessionId.HasValue) { foreach (Target item in share.Targets.Take(10)) { Db.Share DbShare = new Db.Share(); try { string ShortUrl = String.Format("http://link.tiptrace.com/{0}", UrlCodes[ShareCounter].ToString()); //store in DB DbShare.TargetTypeId = item.SourceType; DbShare.TargetId = item.Identifier; DbShare.TargetName = item.Name; DbShare.DateAdded = DateTime.Now; DbShare.ShareSessionId = ShareSessionId.Value; DbShare.ShortUrl = UrlCodes[ShareCounter].ToString(); if (item.SourceType == 1) //facebook { Facebook.Postmessage(this.UserHash, item.Identifier, share.Message, share.Url, ShortUrl); WithFacebookShare = true; //throw new Exception("FOUT!!"); } if (item.SourceType == 2) //linkedin { Response = LinkedIn.Postmessage(this.UserHash, item.Identifier, share.Message, share.Url, ShortUrl); } if (item.SourceType == 5) //twitter { Response = Twitter.Postmessage(this.UserHash, item.Identifier, share.Message, share.Url, ShortUrl); } if (item.SourceType == 3 || item.SourceType == 4) //Google || Hotmail { //Get the name of the sharer Db.UserSource Source = (from usersource in db.UserSources where usersource.User.Hash == this.UserHash && usersource.SourceTypeId == item.SourceType select usersource).FirstOrDefault(); //Load and parse the template string EmailTemplate = getEmailTemplate(share.ClientHash); string EmailContent = EmailTemplate.Replace("{SourceName}", Source.Name); EmailContent = EmailContent.Replace("{SourceEmail}", Source.Identifier); EmailContent = EmailContent.Replace("{TargetName}", item.Name); EmailContent = EmailContent.Replace("{TargetEmail}", item.Identifier); EmailContent = EmailContent.Replace("{Link}", string.Format("<a href='{0}'>{1}</a>", ShortUrl, share.Url.Value)); EmailContent = EmailContent.Replace("{Message}", share.Message); Utility.Email.SendEmail(Source.Identifier, Source.Name, item.Identifier, item.Name, string.Format("Tip from {1}: {0}", share.Url.Title, Source.Identifier), EmailContent); } if (item.SourceType == 6) //email { //Load and parse the template string EmailTemplate = getEmailTemplate(share.ClientHash); string EmailContent = EmailTemplate.Replace("{SourceName}", EmailName); EmailContent = EmailContent.Replace("{SourceEmail}", EmailIdentifier); EmailContent = EmailContent.Replace("{TargetName}", item.Name); EmailContent = EmailContent.Replace("{TargetEmail}", item.Identifier); EmailContent = EmailContent.Replace("{Link}", string.Format("<a href='{0}'>{1}</a>", ShortUrl, share.Url.Value)); EmailContent = EmailContent.Replace("{Message}", share.Message); //Send the email Utility.Email.SendEmail(EmailIdentifier, EmailName, item.Identifier, item.Name, string.Format("Tip from {1}: {0}", share.Url.Title, EmailIdentifier), EmailContent); } DbShare.ShareStatusID = 1; share.Status = "succes"; } catch (Exception ex) { DbShare.ShareStatusID = 2; DbShare.ShareStatus = ex.Message + "" + Response; share.Status = "failed" + ex.Message; } finally { db.Shares.AddObject(DbShare); } ShareCounter++; } db.SaveChanges(); share.ShareSessionId = ShareSessionId.Value; if (WithFacebookShare) { Facebook.CloseChatConnection(); } } return(Json(share, JsonRequestBehavior.AllowGet)); }
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)); }