/// <summary> /// Delete a notification /// </summary> /// <param name="notification"></param> public void Delete(CategoryNotification notification) { ContextPerRequest.Db.CategoryNotification.Remove(notification); }
/// <summary> /// Add a new category notification /// </summary> /// <param name="category"></param> public void Add(CategoryNotification category) { ContextPerRequest.Db.CategoryNotification.Add(category); }
public void Subscribe(SubscribeEmailViewModel subscription) { if (Request.IsAjaxRequest()) { using (var unitOfWork = UnitOfWorkManager.NewUnitOfWork()) { try { // Add logic to add subscr var isCategory = subscription.SubscriptionType.Contains("category"); var id = subscription.Id; if (isCategory) { // get the category var cat = ServiceFactory.CategoryService.Get(Convert.ToInt32(id)); if (cat != null) { // Create the notification var categoryNotification = new CategoryNotification { Category = cat, CategoryId = cat.Id, Member = CurrentMember, MemberId = CurrentMember.Id }; //save ServiceFactory.CategoryNotificationService.Add(categoryNotification); } } else { // get the category var topic = ServiceFactory.TopicService.Get(new Guid(id)); // check its not null if (topic != null) { // Create the notification var topicNotification = new TopicNotification { Topic = topic, Member = CurrentMember, MemberId = CurrentMember.Id }; ServiceFactory.TopicNotificationService.Add(topicNotification); } } unitOfWork.Commit(); } catch (Exception ex) { unitOfWork.Rollback(); LogError(ex); throw new Exception(Lang("Errors.GenericMessage")); } } } else { throw new Exception(Lang("Errors.GenericMessage")); } }