Exemplo n.º 1
0
        public Favourite Add(Favourite favourite)
        {
            var e = new FavouriteEventArgs { Favourite = favourite };
            EventManager.Instance.FireBeforeFavourite(this, e);

            if (!e.Cancel)
            {
                favourite = _favouriteRepository.Add(favourite);

                EventManager.Instance.FireAfterFavourite(this, new FavouriteEventArgs { Favourite = favourite});
            }

            return favourite;
        }
Exemplo n.º 2
0
 public Favourite Delete(Favourite favourite)
 {
     return _favouriteRepository.Delete(favourite);
 }
Exemplo n.º 3
0
 public Favourite Delete(Favourite dialogueFavourite)
 {
     return _context.Favourite.Remove(dialogueFavourite);
 }
Exemplo n.º 4
0
 public Favourite Add(Favourite dialogueFavourite)
 {
     return _context.Favourite.Add(dialogueFavourite);
 }
Exemplo n.º 5
0
 public Favourite Delete(Favourite favourite)
 {
     return _context.Favourite.Remove(favourite);
 }
Exemplo n.º 6
0
        public JsonResult FavouritePost(FavouritePostViewModel viewModel)
        {
            var returnValue = new FavouriteJsonReturnModel();
            if (Request.IsAjaxRequest() && LoggedOnReadOnlyUser != null)
            {
                using (var unitOfwork = UnitOfWorkManager.NewUnitOfWork())
                {
                    try
                    {
                        var post = _postService.Get(viewModel.PostId);
                        var topic = _topicService.Get(post.Topic.Id);

                        // See if this is a user adding or removing the favourite
                        var loggedOnUser = MembershipService.GetUser(LoggedOnReadOnlyUser.Id);
                        var existingFavourite = _favouriteService.GetByMemberAndPost(loggedOnUser.Id, post.Id);
                        if (existingFavourite != null)
                        {
                            _favouriteService.Delete(existingFavourite);
                            returnValue.Message = LocalizationService.GetResourceString("Post.Favourite");
                        }
                        else
                        {
                            var favourite = new Favourite
                            {
                                DateCreated = DateTime.UtcNow,
                                Member = loggedOnUser,
                                Post = post,
                                Topic = topic
                            };
                            _favouriteService.Add(favourite);
                            returnValue.Message = LocalizationService.GetResourceString("Post.Favourited");
                            returnValue.Id = favourite.Id;
                        }

                        unitOfwork.Commit();
                        return Json(returnValue, JsonRequestBehavior.DenyGet);
                    }
                    catch (Exception ex)
                    {
                        unitOfwork.Rollback();
                        LoggingService.Error(ex);
                        throw new Exception(LocalizationService.GetResourceString("Errors.Generic"));
                    }
                }
            }
            return Json(returnValue);
        }
Exemplo n.º 7
0
 public Favourite Delete(Favourite dialogueFavourite)
 {
     return _favouriteRepository.Delete(dialogueFavourite);
 }
Exemplo n.º 8
0
 public Favourite Add(Favourite dialogueFavourite)
 {
     return _favouriteRepository.Add(dialogueFavourite);
 }