public async Task <IActionResult> SendEmail(int id, string isOwner) { NotificationOrder notificationOrder = await db.NotificationsOrder.FirstOrDefaultAsync(p => p.OrderId == id); EmailService emailService = new EmailService(); if (isOwner == "order") { await emailService.SendEmailAsync(notificationOrder.OrderOwnerEmail, notificationOrder.NotificationTitle, notificationOrder.NotificationTitle); } else { await emailService.SendEmailAsync(notificationOrder.ReceiverEmail, notificationOrder.NotificationTitle, notificationOrder.NotificationTitle); } return(Ok()); }
public async Task CreateNotification(TaxiOrder taxiOrder) { NotificationOrder notificationOrder = new NotificationOrder(); notificationOrder.OrderOwnerId = taxiOrder.OrderOwnerId; notificationOrder.OrderOwnerEmail = taxiOrder.OrderOwnerEmail; notificationOrder.ReceiverId = taxiOrder.ReceiverId; notificationOrder.ReceiverEmail = taxiOrder.ReceiverEmail; notificationOrder.OrderId = taxiOrder.Id; notificationOrder.OrderStatus = taxiOrder.OrderStatus; notificationOrder.NotificationStatusClient = "Free"; notificationOrder.NotificationStatusCarrier = "Free"; notificationOrder.NotificationTitle = "Заказ " + taxiOrder.StartPoint.Remove(0, taxiOrder.StartPoint.IndexOf('|') + 1) + " - " + taxiOrder.EndPoint.Remove(0, taxiOrder.EndPoint.IndexOf('|') + 1) + " был принят. "; db.NotificationsOrder.Add(notificationOrder); await db.SaveChangesAsync(); }
public async Task <IActionResult> SetNotificationStatusClient(int id, string status) { if (id != null) { NotificationOrder notification = await db.NotificationsOrder.FirstOrDefaultAsync(n => n.NotificationId == id); notification.NotificationStatusClient = status; db.NotificationsOrder.Update(notification); await db.SaveChangesAsync(); List <NotificationOrder> ns = await db.NotificationsOrder.ToListAsync(); return(Json(ns, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() })); } return(NotFound()); }