public ActionResult Tracking() { string urlKey = Request.QueryString["k"]; if (string.IsNullOrWhiteSpace(urlKey) || urlKey != OpenpayWebhookKey) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } System.IO.StreamReader reader = new System.IO.StreamReader(HttpContext.Request.InputStream); string rawJSON = reader.ReadToEnd(); System.Diagnostics.Trace.TraceInformation("PaymentsController [rawJSON] : " + rawJSON); // For debugging to the Azure Streaming logs PaymentEventModel paymentEvent = JsonConvert.DeserializeObject <PaymentEventModel>(rawJSON); if (paymentEvent != null) { if (!string.IsNullOrWhiteSpace(paymentEvent.type)) { System.Diagnostics.Trace.TraceInformation("\tTransaction: " + paymentEvent.transaction); if (paymentEvent.transaction != null) { System.Diagnostics.Trace.TraceInformation("\t\t Transaction Id: " + paymentEvent.transaction.id); System.Diagnostics.Trace.TraceInformation("\t\t Order Id: " + paymentEvent.transaction.order_id); System.Diagnostics.Trace.TraceInformation("\t\t Authorization: " + paymentEvent.transaction.authorization); Payment paymentBO = _paymentService.GetByOrderId(paymentEvent.transaction.order_id); User user = paymentBO.User;//_userService.GetById(payment.User.Id); if (paymentBO != null) { System.Diagnostics.Trace.TraceInformation("\t\t Payment BO ID: " + paymentBO.Id); paymentBO.Status = paymentEvent.transaction.status; paymentBO.LogData = rawJSON; if (paymentEvent.type == PaymentEventStatus.CHARGE_SUCCEEDED) { paymentBO.ConfirmationDate = DateUtil.GetDateTimeNow(); //lo tomamos cuando llega el evento paymentBO.AuthorizationCode = paymentEvent.transaction.authorization; Dictionary <string, string> customParams = new Dictionary <string, string>(); customParams.Add("param1", user.FirstName); customParams.Add("param2", paymentEvent.transaction.order_id); customParams.Add("param3", paymentBO.AuthorizationCode); customParams.Add("param4", paymentEvent.transaction.id); customParams.Add("param5", paymentBO.ConfirmationDate.Value.ToString(Constants.DATE_FORMAT)); customParams.Add("param6", string.Format("{0:#.00}", paymentBO.Amount)); customParams.Add("param7", paymentBO.Method); string confirmationEmail = !string.IsNullOrWhiteSpace(paymentBO.ConfirmationEmail) ? paymentBO.ConfirmationEmail : user.Email; NotificationUtil.SendNotification(confirmationEmail, customParams, Constants.NOT_TEMPLATE_CHARGESUCCESS); } _paymentService.Update(paymentBO); System.Diagnostics.Trace.TraceInformation("\t\t Payment BO Status Updated: " + paymentBO.Status); } } } } return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
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 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 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")); } }
protected override void OnTaskStateChanged(TaskState taskState) { if (taskState.Action.IsRemoveAction) { return; } Notification notification = null; byte[] bytes = new byte[taskState.Action.Data.Count]; taskState.Action.Data.CopyTo(bytes, 0); if (taskState.State == TaskState.StateCompleted) { notification = DownloadNotificationUtil.BuildDownloadCompletedNotification( /* context= */ this, Resource.Drawable.exo_controls_play, CHANNEL_ID, /* contentIntent= */ null, Utils.FromUtf8Bytes(bytes)); } else if (taskState.State == TaskState.StateFailed) { notification = DownloadNotificationUtil.BuildDownloadFailedNotification( /* context= */ this, Resource.Drawable.exo_controls_play, CHANNEL_ID, /* contentIntent= */ null, Utils.FromUtf8Bytes(bytes)); } int notificationId = FOREGROUND_NOTIFICATION_ID + 1 + taskState.TaskId; NotificationUtil.SetNotification(this, notificationId, notification); }
protected void Application_Start() { //For azure storage CloudStorageAccount.SetConfigurationSettingPublisher( (configName, configSettingPublisher) => { var connectionString = RoleEnvironment.GetConfigurationSettingValue(configName); configSettingPublisher(connectionString); } ); AreaRegistration.RegisterAllAreas(); RegisterRoutes(RouteTable.Routes); AgileFx.I18n.Configure(() => new canyoucode.Web.I18n.Handler()); DataContext.Configure(ConfigurationManager.ConnectionStrings["CanYouCodeDb"].ConnectionString); NotificationUtil.Init(ConfigurationManager.AppSettings["SMTP_HOST"], ConfigurationManager.AppSettings["SMTP_PORT"], HttpContext.Current.Server.MapPath(ConfigurationManager.AppSettings["MailTemplatesDirectory"])); Tenant.GetAll(); }
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); }
/// <summary> /// Resets all notifications and clears them from cache /// </summary> private void Reset() { #if UNITY_ANDROID NotificationUtil.ClearNotifications(); #endif #if UNITY_IHPONE NotificationServices.CancelAllLocalNotifications(); #endif }
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 async Task <IActionResult> Inbox(int?pageNumber, string query = null) { var user_id = _userManager.GetUserId(HttpContext.User); int pageSize = 25; var notifications = NotificationUtil.Get().Where(e => e.user_id == user_id); if (!string.IsNullOrEmpty(query)) { notifications = notifications.Where(e => e.notification.Contains(query)); } return(View(await PaginatedList <mp_notification> .CreateAsync(notifications.OrderByDescending(e => e.created_at).AsNoTracking(), pageNumber ?? 1, pageSize))); }
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 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 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 ActionResult ResetPassword(RecoverPasswordViewModel model) { if (!ModelState.IsValid) { return(Json(new { success = false, issue = model, errors = ModelState.Keys.Where(k => ModelState[k].Errors.Count > 0) .Select(k => new { propertyName = k, errorMessage = ModelState[k].Errors[0].ErrorMessage }) })); } try { var resultado = _userService.FindBy(e => e.Email == model.Email).First(); if (resultado != null) { ViewBag.mensajeError = string.Empty; resultado.ExpiraToken = System.DateTime.Now.AddDays(1); string token = (resultado.Uuid + "@" + DateTime.Now.AddDays(1).ToString()); token = EncryptorText.DataEncrypt(token).Replace("/", "!!").Replace("+", "$"); resultado.Token = token; Dictionary <string, string> customParams = new Dictionary <string, string>(); string urlAccion = (string)ConfigurationManager.AppSettings["_UrlServerAccess"]; string link = urlAccion + "Auth/AccedeToken?token=" + token; customParams.Add("param1", resultado.Email); customParams.Add("param2", link); NotificationUtil.SendNotification(resultado.Email, customParams, Constants.NOT_TEMPLATE_PASSWORDRECOVER); _userService.Update(resultado); AddViewMessage(TypeMessageView.SUCCESS, Messages.RequestSuccessful); return(View("Login")); } } catch (Exception ex) { //ErrorController.SaveLogError(this, listAction.Update, "RecuperarContrasena", ex); } ModelState.AddModelError("Email", "No se encontró ninguna cuenta con el correo proporcionado. Verifique su información."); return(Json(new { success = false, issue = model, errors = ModelState.Keys.Where(k => ModelState[k].Errors.Count > 0) .Select(k => new { propertyName = k, errorMessage = ModelState[k].Errors[0].ErrorMessage }) })); }
private DisplayMarkerViewModel(int displayIndex) { var screen = NotificationUtil.GetScreenOfIndex(displayIndex); if (screen == null) { return; } var warea = screen.WorkingArea; if (warea.Width < 1 || warea.Height < 1) { return; } this._left = (int)((warea.Width - 300) / 2 + warea.Left); this._top = (int)((warea.Height - 60) / 2 + warea.Top); }
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 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 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); })); } }
private static void GameLoaded(EventArgs args) { try { var handle = Activator.CreateInstance(null, "LevelZero.Core.Champions." + Player.Instance.ChampionName); var pluginModel = (PluginModel)handle.Unwrap(); NotificationUtil.DrawNotification(new NotificationModel(Game.Time, 20f, 1f, ObjectManager.Player.ChampionName + " Loaded !", Color.DeepSkyBlue)); /* * Anyone wants your name here ? */ NotificationUtil.DrawNotification(new NotificationModel(Game.Time, 20f, 1f, "Addon by: MrArticuno", Color.White)); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); NotificationUtil.DrawNotification(new NotificationModel(Game.Time, 20f, 1f, ObjectManager.Player.ChampionName + " is Not Supported", Color.Red)); } }
public async Task <IActionResult> Get() { var email = _userManager.GetUserId(HttpContext.User); var user = await _userManager.FindByEmailAsync(email); var notifications = NotificationUtil.Get().Where(e => e.user_id == user.Id); //if (!string.IsNullOrEmpty(query)) //{ // //} if (!notifications.Any()) { return(Ok(new List <mp_notification>())); } return(Ok(notifications)); }
/// <summary> /// Sends a queue of notifications to the client /// </summary> public void Send() { Reset(); foreach (var stamp in Enum.GetValues(typeof(IterationStamp)).Cast <IterationStamp>()) { var notification = _notifications .FirstOrDefault(x => x.Condition.Invoke(stamp, _manny.Attribute)); #if UNITY_ANDROID NotificationUtil.Send(TimeSpan.FromMinutes((int)stamp), notification.Message); #endif #if UNITY_IPHONE var iosNotification = new LocalNotification { fireDate = DateTime.Now.AddMinutes((int)stamp), alertBody = notification.Message, alertAction = "Manny" }; NotificationServices.ScheduleLocalNotification(iosNotification); #endif } }
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 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 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); }
public HttpResponseMessage Recover([FromUri(Name = "email")] string email) { try { var user = _userService.FindBy(e => e.Email == email).FirstOrDefault(); if (user == null) { return(CreateErrorResponse(HttpStatusCode.BadRequest, "El correo electrónico solicitado no se encuentra registrado.")); } if (user.Role.Code != Constants.ROLE_DEFAULT_API) { return(CreateErrorResponse(HttpStatusCode.BadRequest, "El usuario no cuenta con acceso al API")); } string token = (user.Uuid + "@" + DateTime.Now.AddDays(1).ToString()); token = EncryptorText.DataEncrypt(token).Replace("/", "!!").Replace("+", "$"); List <string> Email = new List <string>(); Email.Add(user.Email); Dictionary <string, string> customParams = new Dictionary <string, string>(); string urlAccion = ConfigurationManager.AppSettings["_UrlServerAccess"].ToString(); string link = urlAccion + "Auth/AccedeToken?token=" + token; customParams.Add("param1", user.Email); customParams.Add("param2", link); string template = "aa61890e-5e39-43c4-92ff-fae95e03a711"; NotificationUtil.SendNotification(Email, customParams, template); user.ExpiraToken = DateUtil.GetDateTimeNow().AddDays(1); user.Token = token; _userService.Update(user); return(CreateResponse("OK", "Datos devueltos correctamente")); } catch (Exception e) { return(CreateErrorResponse(e)); } }
public async Task <IActionResult> PostPrescription(mp_prescription prescription) { var user_id = _userManager.GetUserId(HttpContext.User); var clinician = _clinicianService.Get().FirstOrDefault(e => e.user_id == user_id); prescription.clinician_id = clinician.id; prescription.created_by = user_id; var prescription_id = _prescriptionService.AddPrescription(prescription); var collection = Request.Form; var drugs = collection["drug"].ToList(); var dosages = collection["dosage"].ToList(); var drug_text = ""; var prescription_drugs = new List <mp_prescription_drug>(); for (var i = 0; i < drugs.Count; i++) { prescription_drugs.Add(new mp_prescription_drug { drug = drugs[i], dosage = dosages[i], prescription_id = prescription_id }); drug_text += drugs[i] + " " + dosages[i] + ","; } _prescriptionService.AddPrescriptionDrugs(prescription_drugs); //get the profile information var profile = _profileService.Get(prescription.profile_id); var notification = new mp_notification { created_by = "sys_admin", created_by_name = "System Admin", notification_type = 7, read = 0, user_id = profile.user_id, notification = "Hi " + profile.last_name + " " + profile.first_name + ", Your prescription information has been updated, check your prescriptions for the details.", title = "New Prescription" }; NotificationUtil.Add(notification); await _emailSender.SendEmailAsync(profile.email, "New Prescription - MySpace MyTime", $"Hi " + profile.last_name + " " + profile.first_name + ", Your prescription information has been updated, check your prescriptions for the details."); if (prescription.pharmacy_id.HasValue) { //get the email of the pharmacy var pharmacy = _pharmacyService.Get().FirstOrDefault(e => e.id == prescription.pharmacy_id.Value); if (pharmacy != null && !string.IsNullOrEmpty(pharmacy.email)) { await _emailSender.SendEmailAsync(profile.email, "New Prescription - MySpace MyTime", $"The following prescriptions have been sent for " + profile.last_name + " " + profile.first_name + " - " + profile.unique_id.ToString("D10") + " .<br/>" + drug_text); } } return(Ok(200)); }
static void Init() { NotificationUtil.Init(ConfigurationManager.AppSettings["SMTP_HOST"], ConfigurationManager.AppSettings["SMTP_PORT"], ConfigurationManager.AppSettings["MailTemplatesDirectory"]); }