public void Favourite(EntityIdViewModel favouriteViewModel) { try { var favourite = _favouriteService.Get(favouriteViewModel.Id); var databaseUpdateNeeded = _badgeService.ProcessBadge(BadgeType.Favourite, favourite.Member) | _badgeService.ProcessBadge(BadgeType.Favourite, favourite.Post.User); if (databaseUpdateNeeded) { Context.SaveChanges(); } } catch (Exception ex) { Context.RollBack(); LoggingService.Error(ex); } }
public void Favourite(FavouriteViewModel favouriteViewModel) { using (var unitOfwork = UnitOfWorkManager.NewUnitOfWork()) { try { var favourite = _favouriteService.Get(favouriteViewModel.FavouriteId); var databaseUpdateNeeded = _badgeService.ProcessBadge(BadgeType.Favourite, favourite.Member) | _badgeService.ProcessBadge(BadgeType.Favourite, favourite.Post.User); if (databaseUpdateNeeded) { unitOfwork.Commit(); } } catch (Exception ex) { unitOfwork.Rollback(); LoggingService.Error(ex); } } }
public virtual async Task <ActionResult> Favourite(EntityIdViewModel favouriteViewModel) { try { var favourite = _favouriteService.Get(favouriteViewModel.Id); var databaseUpdateNeeded = await _badgeService.ProcessBadge(BadgeType.Favourite, favourite.Member) | await _badgeService.ProcessBadge(BadgeType.Favourite, favourite.Post.User); if (databaseUpdateNeeded) { await Context.SaveChangesAsync(); } } catch (Exception ex) { Context.RollBack(); LoggingService.Error(ex); } // TODO - Should be returning something meaningful! return(Content(string.Empty)); }