public ActionResult DeleteAccount(string key) { var token = DbContext.Token.FirstOrDefault(t => t.Key == key && t.Type == TOKEN_TYPE.MARKETING_INVITE); if (token != null) { var account = DbContext.Account.LoadRelated(a => a.Company.Portfolio, a => a.Company.Consultants, a => a.Company.Bids) .Single(a => a.Username == token.Data); account.Company.Portfolio.ToList().ForEach(p => p.Delete(DbContext)); account.Company.Consultants.ToList().ForEach(c => c.Delete(DbContext)); account.Company.Bids.ToList().ForEach(b => b.Delete(DbContext)); account.Company.Delete(DbContext); account.Delete(DbContext); token.Delete(DbContext); DbContext.SaveChanges(); Response.Cookies["PreviewMode"].Expires = DateTime.Now; FormsAuthentication.SignOut(); try { NotificationUtil.SendAdminEmail(string.Format("Marketing Account, Delete - Username {0}", account.Username), ""); } catch { } return(Redirect(string.Format("/?Message={0}", MessageCodes.ACCOUNT_REMOVED))); } else { return(Redirect("/Login")); } }
public ActionResult ActivateAccount(string key) { var token = DbContext.Token.FirstOrDefault(t => t.Key == key && t.Type == TOKEN_TYPE.MARKETING_INVITE); if (token != null) { token.Delete(DbContext); var account = DbContext.Account.Single(a => a.Username == token.Data); account.Status = ACCOUNT_STATUS.ACTIVE; DbContext.SaveChanges(); Response.Cookies["PreviewMode"].Expires = DateTime.Now; try { NotificationUtil.SendAdminEmail(string.Format("Marketing Account, Activate - Username {0}", account.Username), ""); } catch { } return(Redirect("/" + account.Username + "/SetupAccount")); } else { return(Redirect("/Login")); } }
public ActionResult Preview(string key) { var token = DbContext.Token.FirstOrDefault(t => t.Key == key && t.Type == TOKEN_TYPE.MARKETING_INVITE); if (token != null) { var account = DbContext.Account.Single(a => a.Username == token.Data); Response.Cookies.Add(AuthHelper.GetAuthTicketWithRoles(account.Username, account.Type, true, new TimeSpan(0, 30, 0))); Response.Cookies.Add(new HttpCookie("PreviewMode", token.Key) { Expires = DateTime.Now.Add(new TimeSpan(0, 30, 0)) }); try { NotificationUtil.SendAdminEmail(string.Format("Marketing Account, Preview - Username {0}", account.Username), ""); } catch { } return(Redirect("/" + account.Username)); } else { return(Redirect("/Login")); } }
public void PlaceBid(long projectId, int hoursOfEffort, string timeframe, int?minQuote, int?maxQuote, string message) { if (!this.IsLoaded(c => c.Account)) { this.Load(this.EntityContext, c => c.Account); } if (this.Account.Status == ACCOUNT_STATUS.DISABLED) { throw new Exception(MessageCodes.ACTIVATE_ACCOUNT_TO_BID); } var project = this.DbContext().Project .LoadRelated(p => p.Employer.Account) .Where(p => p.Id == projectId).Single(); if (!this.IsLoaded(c => c.Account)) { this.Load(this.EntityContext, c => c.Account); } if (!this.IsLoaded(c => c.ProjectInvites)) { this.Load(this.EntityContext, c => c.ProjectInvites); this.LoadInCollection(this.EntityContext, c => c.ProjectInvites, pi => pi.Project); } var bid = new Bid(); bid.Company = this; bid.Project = project; bid.DateCreated = DateTime.Now; bid.Invited = false; bid.Message = message; bid.MinQuote = minQuote; bid.MaxQuote = maxQuote; bid.Status = BID_STATUS.NEW; bid.HoursOfEffort = hoursOfEffort; bid.Timeframe = timeframe; bid.TenantId = TenantId; string subject = string.Format("You have received a new bid for Project - {0}", project.Title); NotificationUtil.SendSystemEmailWithTemplate(project.Employer.Account.Email, subject, EMAIL_TEMPLATES.NEW_BID_TEMPLATE, project.Employer.Name, this.Name, this.Id.ToString(), string.Format("{0}, {1} {2}", this.Name, this.City, this.Country), this.Account.Username); NotificationUtil.SendAdminEmail(string.Format("Bid placed by {0} ID:{1} on Project {2} ID:{3}", bid.Company.Name, bid.CompanyId, bid.Project.Title, bid.ProjectId), ""); if (this.ProjectInvites.Any(pi => pi.Status == PROJECT_INVITE_STATUS.NEW && pi.ProjectId == projectId)) { bid.Invited = true; this.ProjectInvites.Single(pi => pi.ProjectId == projectId).Status = PROJECT_INVITE_STATUS.ACCEPTED; } this.EntityContext.AddObject(bid); }
public static void Create(string name, string slug, long tenantId, EntityContext context) { var tag = new Tag(); tag.Name = name; tag.Slug = slug; tag.TenantId = tenantId; context.AddObject(tag); NotificationUtil.SendAdminEmail(string.Format("New Tag - Name:{0} Slug:{1}", name, slug), ""); }
public static Tag Create(string name, long tenantId, EntityContext context) { var tag = new Tag(); name = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(name.Trim().ToLowerInvariant()); var slug = new Regex("[a-zA-Z_]*").Match(name.Replace(" ", "_")).Value; tag.Name = name.Trim(); tag.Slug = slug; tag.TenantId = tenantId; context.AddObject(tag); NotificationUtil.SendAdminEmail(string.Format("New Tag - Name:{0} Slug:{1}", name, slug), ""); return(tag); }
public Project CreateProject(string title, string description, int budget, string currency, DateTime closingDate, IEnumerable <long> tagIds, IEnumerable <string> tagNames, HttpPostedFileBase postedFile) { var project = new Project(); project.Title = title; project.Description = description; project.Budget = budget; project.Currency = currency; project.ClosingDate = closingDate; project.Employer = this; project.Status = PROJECT_STATUS.NEW; project.DateAdded = DateTime.Now; project.DescriptionText = Regex.Replace(description, "<.*?>", string.Empty); project.TenantId = TenantId; if (postedFile != null && postedFile.ContentLength > 0) { project.AddAttachment(postedFile, TenantId); } var tags = this.DbContext().Tag.Where(t => tagIds.Contains(t.Id)).ToList(); tags.ForEach(t => project.Tags.Add(t)); if (tagNames != null && tagNames.Count() > 0) { var existingTagNames = tags.Select(t => t.Name); var newTags = tagNames.Select(n => n.Trim()).Where(tn => !string.IsNullOrEmpty(tn) && !existingTagNames.Contains(tn)) .Distinct().Take(10).ToList(); if (newTags.Count() > 0) { newTags.ForEach(t => project.Tags.Add(Tag.Create(t, TenantId, EntityContext))); } } try { if (!this.IsLoaded(e => e.Account)) { this.Load(this.EntityContext, e => e.Account); } NotificationUtil.SendAdminEmail(string.Format("Employer Project Created - Username {0}", this.Account.Username), string.Format("project title - {0}", title)); } catch { } return(project); }
public static Employer Create(string name, string city, string country, string username, string password, string email, string phone, long tenantId, EntityContext context) { username = username.Trim(); if (string.IsNullOrEmpty(username)) { throw new Exception("The username cannot be empty"); } if (Account.Exists(username, tenantId)) { throw new Exception("The username already exists."); } var account = new Account(); account.Username = username; account.Password = AgileFx.Security.CryptoUtil.HashPassword(password); account.Status = ACCOUNT_STATUS.ACTIVE; account.LastLoginDate = DateTime.Now; account.DateAdded = DateTime.Now; account.Type = ACCOUNT_TYPE.EMPLOYER; account.Email = email; account.Phone = phone; account.TenantId = tenantId; var employer = new Employer(); employer.Account = account; employer.Name = name; employer.City = city; employer.Country = country; employer.IsVerified = false; employer.TenantId = tenantId; context.AddObject(employer); try { NotificationUtil.SendAdminEmail(string.Format("Employer Signup - Username {0}", username), ""); } catch { } return(employer); }
public JsonResult SendMessage(string type, string recipientName, string recipientEmail, string messageText, string yourname) { try { Message.Send(messageText, recipientEmail, recipientName, type, yourname); NotificationUtil.SendAdminEmail("SendMessage-Copy", string.Format("Message Text:{0} Email:{1} rec-Name:{2} Type{3} Name{4}", messageText, recipientEmail, recipientName, type, yourname)); return(Json(new AjaxResponse <bool> { Success = true, MessageCode = MessageCodes.SENT })); } catch (Exception) { return(Json(new AjaxResponse <bool> { Success = false, MessageCode = MessageCodes.SEND_FAILED })); } }
public ActionResult Login(string Username, string Password, string returnUrl) { NotificationUtil.SendAdminEmail(string.Format("Login Page Attempted - Username {0}", Username), ""); Account acct = Account.VerifyCredentials(Username, Password, Tenant.Id); if (acct != null) { Response.Cookies.Add(AuthHelper.GetAuthTicketWithRoles(acct.Username, acct.Type, true, new TimeSpan(0, 30, 0))); if (acct.Type != ACCOUNT_TYPE.ADMIN) { if (acct.Type == ACCOUNT_TYPE.COMPANY) { var company = DbContext.Company.Where(c => c.Account == acct) .LoadRelated(c => c.Portfolio, c => c.Account, c => c.Consultants, c => c.Tags) .Single(); if (company.GetInvites().Count() <= 0 && company.GetActiveBids().Count() <= 0) { return(Redirect("/" + Username)); } } if (!string.IsNullOrWhiteSpace(returnUrl)) { return(Redirect(returnUrl)); } return(Redirect("/" + Username + "/Projects")); } else { return(Redirect("/Admin/Index")); } NotificationUtil.SendAdminEmail(string.Format("Login Page Successfull - Username {0}", Username), ""); } else { return(View <Login>(GetViewName("Login"), v => { v.Username = Username; v.AddError(MessageCodes.PASSWORD_MISMATCH); })); } }
public JsonResult Contact(long recipientId, string senderName, string senderEmail, string message) { try { if (string.IsNullOrEmpty(senderEmail) || string.IsNullOrEmpty(senderName)) { throw new InvalidOperationException(); } Message.Send(recipientId, senderName, senderEmail, message, LoggedInAccount, DbContext); NotificationUtil.SendAdminEmail("SendMessage-Copy", string.Format("Message Text:{0} Email:{1} Name{2} recid:{3}", message, senderEmail, senderName, recipientId)); return(Json(new AjaxResponse <bool> { Success = true, MessageCode = MessageCodes.SENT })); } catch (Exception) { return(Json(new AjaxResponse <bool> { Success = false, MessageCode = MessageCodes.SEND_FAILED })); } }
public static Company Create(string companyName, string website, string city, string country, string username, string password, int?minimumRate, string currency, string email, string phone, string type, long tenantId, Entities context) { username = username.Trim(); if (string.IsNullOrEmpty(username)) { throw new Exception("The username cannot be empty"); } if (Account.Exists(username, tenantId)) { throw new Exception("The username already exists."); } var account = new Account(); account.Username = username; account.Password = AgileFx.Security.CryptoUtil.HashPassword(password); account.Status = ACCOUNT_STATUS.ACTIVE; account.LastLoginDate = DateTime.Now; account.DateAdded = DateTime.Now; account.Type = ACCOUNT_TYPE.COMPANY; account.Email = email; account.Phone = phone; account.TenantId = tenantId; var company = new Company(); company.Account = account; company.Name = companyName; company.Website = website; company.City = city; company.Country = country; company.MinimumRate = minimumRate; company.Currency = currency; company.Logo = DEFAULT_IMAGES.COMPANY_LOGO; company.Type = type; company.Description = ""; company.Style = PORTFOLIO_STYLE.SIMPLE; company.TenantId = tenantId; if (type == COMPANY_TYPE.INDIVIDUAL) { company.Logo = DEFAULT_IMAGES.PROFILE_PICTURE; } foreach (var tag in context.Tag.Where(t => t.Name == "Web Design" || t.Name == "")) { company.Tags.Add(tag); } //Add a few portfolio entries company.Add_ImageAndDescription_Page(PORTFOLIO_ENTRY_TYPE.IMAGE, "Sample 1", "", DEFAULT_IMAGES.PAGE_PLACEHOLDER); company.Add_ImageAndDescription_Page(PORTFOLIO_ENTRY_TYPE.IMAGE, "Sample 2", "", DEFAULT_IMAGES.PAGE_PLACEHOLDER2); company.Add_ImageAndDescription_Page(PORTFOLIO_ENTRY_TYPE.IMAGE, "Sample 3", "", DEFAULT_IMAGES.PAGE_PLACEHOLDER3); //var projects = context.Project.Where(p => p.Employer.Account.Username == "bouncethru"); //create an active bid for one of the sample projects. //var activeProject = projects.Where(p => p.ClosingDate >= DateTime.Now).First(); //company.PlaceBid(activeProject.Id, 200, TIMEFRAME.MONTHS_2, 10000, 50000, "I am bidding on this sample project."); context.AddObject(company); try { NotificationUtil.SendAdminEmail(string.Format("Company Signup - Username {0}", username), ""); } catch { } return(company); }
public ActionResult Login(string username) { NotificationUtil.SendAdminEmail(string.Format("Login Page Request - Username {0}", username), ""); return(View <Login>(v => v.Username = username)); }