Пример #1
0
 public void Update(CategoryNotification item)
 {
     // Check there's not an object with same identifier already in context
     if (_context.CategoryNotification.Local.Select(x => x.Id == item.Id).Any())
     {
         throw new ApplicationException("Object already exists in context - you do not need to call Update. Save occurs on Commit");
     }
     _context.Entry(item).State = EntityState.Modified;
 }
        public ActionResult Add(string description, string color, string icon)
        {
            try
            {
                var category = new CategoryNotification();

                category.Description = description;
                category.Color       = color;
                category.Icon        = icon;

                _categoryNotificationService.Insert(category);
                _categoryNotificationService.SaveChanges();

                return(Content("1"));
            }
            catch (Exception)
            {
                return(Content("0"));
            }
        }
 public CategoryNotification Insert(CategoryNotification entity)
 {
     return(_CategoryNotificationRepository.Add(entity));
 }
 public void Delete(CategoryNotification entity)
 {
     _CategoryNotificationRepository.Delete(entity);
 }
 /// <summary>
 /// Add a new category notification
 /// </summary>
 /// <param name="category"></param>
 public void Add(CategoryNotification category)
 {
     _categoryNotificationRepository.Add(category);
 }
 /// <summary>
 /// Delete a notification
 /// </summary>
 /// <param name="notification"></param>
 public void Delete(CategoryNotification notification)
 {
     _categoryNotificationRepository.Delete(notification);
 }
Пример #7
0
 /// <inheritdoc />
 public CategoryNotification Add(CategoryNotification category)
 {
     return(_context.CategoryNotification.Add(category));
 }
        /// <summary>
        /// Add a new category notification
        /// </summary>
        /// <param name="category"></param>
        public CategoryNotification Add(CategoryNotification category)
        {
            return _context.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 = 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

                                CategoryNotificationService.Add(categoryNotification);
                            }
                        }
                        else
                        {
                            // get the category
                            var topic = 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
                                };
                                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"));
            }
        }
Пример #10
0
        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 isTag = subscription.SubscriptionType.Contains("tag");
                        var id = subscription.Id;
                        var dbUser = MembershipService.GetUser(LoggedOnReadOnlyUser.Id);

                        if (isCategory)
                        {
                            // get the category
                            var cat = _categoryService.Get(id);

                            if(cat != null)
                            {

                                // Create the notification
                                var categoryNotification = new CategoryNotification
                                {
                                    Category = cat,
                                    User = dbUser
                                };
                                //save

                                _categoryNotificationService.Add(categoryNotification);
                            }
                        }
                        else if (isTag)
                        {
                            // get the tag
                            var tag = _topicTagService.Get(id);

                            if (tag != null)
                            {

                                // Create the notification
                                var tagNotification = new TagNotification
                                {
                                    Tag = tag,
                                    User = dbUser
                                };
                                //save

                                _tagNotificationService.Add(tagNotification);
                            }
                        }
                        else
                        {
                            // get the category
                            var topic = _topicService.Get(id);

                            // check its not null
                            if (topic != null)
                            {

                                // Create the notification
                                var topicNotification = new TopicNotification
                                {
                                    Topic = topic,
                                    User = dbUser
                                };
                                //save

                                _topicNotificationService.Add(topicNotification);
                            }
                        }

                        unitOfWork.Commit();
                    }
                    catch (Exception ex)
                    {
                        unitOfWork.Rollback();
                        LoggingService.Error(ex);
                        throw new Exception(LocalizationService.GetResourceString("Errors.GenericMessage"));
                    }
                }
            }
            else
            {
                throw new Exception(LocalizationService.GetResourceString("Errors.GenericMessage"));
            }
        }
Пример #11
0
        public virtual void Subscribe(EmailSubscriptionViewModel subscription)
        {
            if (Request.IsAjaxRequest())
            {
                try
                {
                    // Add logic to add subscr
                    var isCategory = subscription.SubscriptionType.Contains("category");
                    var isTag      = subscription.SubscriptionType.Contains("tag");
                    var id         = subscription.Id;
                    var dbUser     = MembershipService.GetUser(User.Identity.Name);

                    if (isCategory)
                    {
                        // get the category
                        var cat = _categoryService.Get(id);

                        if (cat != null)
                        {
                            // Create the notification
                            var categoryNotification = new CategoryNotification
                            {
                                Category = cat,
                                User     = dbUser
                            };
                            //save

                            _notificationService.Add(categoryNotification);
                        }
                    }
                    else if (isTag)
                    {
                        // get the tag
                        var tag = _topicTagService.Get(id);

                        if (tag != null)
                        {
                            // Create the notification
                            var tagNotification = new TagNotification
                            {
                                Tag  = tag,
                                User = dbUser
                            };
                            //save

                            _notificationService.Add(tagNotification);
                        }
                    }
                    else
                    {
                        // get the category
                        var topic = _topicService.Get(id);

                        // check its not null
                        if (topic != null)
                        {
                            // Create the notification
                            var topicNotification = new TopicNotification
                            {
                                Topic = topic,
                                User  = dbUser
                            };
                            //save

                            _notificationService.Add(topicNotification);
                        }
                    }

                    Context.SaveChanges();
                }
                catch (Exception ex)
                {
                    Context.RollBack();
                    LoggingService.Error(ex);
                    throw new Exception(LocalizationService.GetResourceString("Errors.GenericMessage"));
                }
            }
            else
            {
                throw new Exception(LocalizationService.GetResourceString("Errors.GenericMessage"));
            }
        }
 /// <summary>
 /// Add a new category notification
 /// </summary>
 /// <param name="category"></param>
 public void Add(CategoryNotification category)
 {
     ContextPerRequest.Db.CategoryNotification.Add(category);
 }
 /// <summary>
 /// Delete a notification
 /// </summary>
 /// <param name="notification"></param>
 public void Delete(CategoryNotification notification)
 {
     ContextPerRequest.Db.CategoryNotification.Remove(notification);
 }
 public void Update(CategoryNotification entity)
 {
     _CategoryNotificationRepository.Update(entity);
 }
Пример #15
0
 /// <inheritdoc />
 public void Delete(CategoryNotification notification)
 {
     _context.CategoryNotification.Remove(notification);
 }
Пример #16
0
        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 = _categoryService.Get(id);

                            if (cat != null)
                            {
                                // Create the notification
                                var categoryNotification = new CategoryNotification
                                {
                                    Category = cat,
                                    User     = LoggedOnUser
                                };
                                //save

                                _categoryNotificationService.Add(categoryNotification);
                            }
                        }
                        else
                        {
                            // get the category
                            var topic = _topicService.Get(id);

                            // check its not null
                            if (topic != null)
                            {
                                // Create the notification
                                var topicNotification = new TopicNotification
                                {
                                    Topic = topic,
                                    User  = LoggedOnUser
                                };
                                //save

                                _topicNotificationService.Add(topicNotification);
                            }
                        }

                        unitOfWork.Commit();
                    }
                    catch (Exception ex)
                    {
                        unitOfWork.Rollback();
                        LoggingService.Error(ex);
                        throw new Exception(LocalizationService.GetResourceString("Errors.GenericMessage"));
                    }
                }
            }
            else
            {
                throw new Exception(LocalizationService.GetResourceString("Errors.GenericMessage"));
            }
        }
Пример #17
0
 /// <summary>
 /// Delete a notification
 /// </summary>
 /// <param name="notification"></param>
 public void Delete(CategoryNotification notification)
 {
     _context.CategoryNotification.Remove(notification);
 }