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 void WithdrawBid(long bidId) { var bid = this.DbContext().Bid .LoadRelated(b => b.Project, b => b.Project.Employer.Account, b => b.Company.Account) .Single(b => b.Id == bidId); bid.Status = BID_STATUS.WITHDRAWN; string subject = string.Format("Bid for Project - {0}, has been withdrawn by {1}", bid.Project.Title, this.Name); NotificationUtil.SendSystemEmailWithTemplate(bid.Project.Employer.Account.Email, subject, EMAIL_TEMPLATES.BID_WITHDRAWN, bid.Project.Employer.Name, bid.Project.Title, bid.ProjectId.ToString(), bid.Company.Name, bid.Company.Account.Username); }
public void CreatePasswordResetToken() { //Get the account in question var account = this.DbContext().Account.LoadRelated(a => a.Company, a => a.Employer) .Single(a => a.Username == Username && a.TenantId == TenantId); //See if there is a token with the same username var token = this.DbContext().Token.FirstOrDefault(t => t.Type == TOKEN_TYPE.PASSWORD_RESET && t.Data == Username && t.TenantId == TenantId); //If not create a new one. if (token == null) { token = Token.Create(TOKEN_TYPE.PASSWORD_RESET, Username, TenantId); this.DbContext().AddObject(token); } else { token.UpdateKey(); } this.DbContext().SaveChanges(); var name = ""; if (account.Type == ACCOUNT_TYPE.COMPANY) { if (!account.IsLoaded(a => a.Company)) { account.Load(this.DbContext(), a => a.Company); } name = account.Company.Name; } else if (account.Type == ACCOUNT_TYPE.EMPLOYER) { if (!account.IsLoaded(a => a.Company)) { account.Load(this.DbContext(), a => a.Company); } name = account.Company.Name; } string subject = "Reset your password"; NotificationUtil.SendSystemEmailWithTemplate(account.Email, subject, EMAIL_TEMPLATES.RESET_PASSWORD, name, account.Username, token.Key); }
public static void Send(string message, string recipientEmail, string recipientName, string type, string senderName) { string from = "*****@*****.**"; string to = "*****@*****.**"; string subject = string.Empty; if (type == SEND_MESSAGE_TYPE.FEEDBACK) { subject = "Feedback from " + senderName; NotificationUtil.SendMail(from, to, subject, message, null); } else { to = recipientEmail; subject = "Invite to Canyoucode from " + senderName; NotificationUtil.SendSystemEmailWithTemplate(to, subject, EMAIL_TEMPLATES.CYC_INVITE, recipientName, senderName); } }
public void Accept() { this.Status = BID_STATUS.ACCEPTED; if (!this.IsLoaded(b => b.Company)) { this.Load(this.EntityContext, b => b.Company); this.Load(this.EntityContext, b => b.Company.Account); } this.Project.Status = PROJECT_STATUS.CLOSED; string subject = string.Format("Your Quote for Project {0} has been accepted. Please contact the customer", this.Project.Title); NotificationUtil.SendSystemEmailWithTemplate(this.Company.Account.Email, subject, BID_ACCEPTED_TEMPLATE, this.Company.Name, GetQuote(), this.Project.Title, this.ProjectId.ToString(), this.Project.Employer.Account.Email, this.Project.Employer.Account.Phone); }
public static void Send(long recipientId, string senderName, string senderEmail, string message, Account account, Entities context) { var recipientAccount = context.Account.Single(a => a.Id == recipientId); string recipientName = string.Empty; if (recipientAccount.Type == ACCOUNT_TYPE.COMPANY) { recipientAccount.Load(context, a => a.Company); recipientName = recipientAccount.Company.Name; } else { recipientAccount.Load(context, a => a.Employer); recipientName = recipientAccount.Employer.Name; } var subject = string.Format("You have a message from {0}", senderName); NotificationUtil.SendSystemEmailWithTemplate(recipientAccount.Email, subject, EMAIL_TEMPLATES.CONTACT_COMPANY, recipientName, senderName, account == null ? senderEmail : account.Email, account == null ? null : account.Phone, message); }
public ProjectInvite SendInvite(long companyId) { var invite = new ProjectInvite(); var company = this.DbContext().Company.LoadRelated(c => c.Account).Single(c => c.Id == companyId); invite.ProjectId = this.Id; invite.CompanyId = companyId; invite.Status = PROJECT_INVITE_STATUS.NEW; if (!this.IsLoaded(p => p.Attachments)) { this.Load(this.EntityContext, p => p.Attachments); } string subject = string.Format("You have been invited to give a quote for Project {0}", this.Title); NotificationUtil.SendSystemEmailWithTemplate(company.Account.Email, subject, EMAIL_TEMPLATES.PROJECT_INVITE_TEMPLATE, company.Name, this.Title, this.Id.ToString(), this.Description, this.Attachments.Count > 0 ? this.Attachments.Single().Token.ToString() : null, this.Budget.ToString()); this.DbContext().AddObject(invite); return(invite); }