public ActionResult Add(NotificationsTB NotificationsTB) { try { if (!ModelState.IsValid) { return(View(NotificationsTB)); } _INotification.DisableExistingNotifications(); var Notifications = new NotificationsTB { CreatedOn = DateTime.Now, Message = NotificationsTB.Message, NotificationsID = 0, Status = "A", FromDate = NotificationsTB.FromDate, ToDate = NotificationsTB.ToDate }; _INotification.AddNotification(Notifications); MyNotificationHub.Send(); return(RedirectToAction("Add", "AddNotification")); } catch (Exception) { throw; } }
/// <summary> /// The AddNotification /// </summary> /// <param name="entity">The entity<see cref="NotificationsTB"/></param> /// <returns>The <see cref="int"/></returns> public int AddNotification(NotificationsTB entity) { try { using (var _context = new DatabaseContext()) { _context.NotificationsTBs.Add(entity); return(_context.SaveChanges()); } } catch (Exception) { throw; } }
public IHttpActionResult Add(NotificationsTB NotificationsTB) { try { this._INotificationRepository.DisableExistingNotifications(); var Notifications = new NotificationsTB { CreatedOn = DateTime.Now, Message = NotificationsTB.Message, NotificationsID = 0, Status = "A", FromDate = NotificationsTB.FromDate, ToDate = NotificationsTB.ToDate }; this._INotificationRepository.AddNotification(Notifications); // MyNotificationHub.Send(); return(Ok()); } catch (Exception) { throw; } }