예제 #1
0
        /// <summary>
        /// Add Navigation to favourite
        /// </summary>
        /// <param name="navigationId"></param>
        /// <returns></returns>
        public ResponseModel AddToFavourites(string navigationId)
        {
            ResponseModel response;

            try
            {
                if (EzWorkContext.CurrentUserId.HasValue)
                {
                    var favouriteNavigation =
                        FetchFirst(f => f.NavigationId == navigationId && f.UserId == EzWorkContext.CurrentUserId);

                    if (favouriteNavigation == null)
                    {
                        var currentFavouriteNavigations = GetCurrentUserFavouriteNavigations();
                        var order = currentFavouriteNavigations.Any()
                            ? currentFavouriteNavigations.Max(f => f.RecordOrder) + 1
                            : 1;
                        favouriteNavigation = new FavouriteNavigation
                        {
                            NavigationId = navigationId,
                            UserId       = EzWorkContext.CurrentUserId.Value,
                            RecordOrder  = order
                        };
                    }
                    response = Insert(favouriteNavigation);

                    response.SetMessage(response.Success
                        ? T("FavouriteNavigation_Message_CreateSuccessfully")
                        : T("FavouriteNavigation_Message_CreateFailure"));
                }
                else
                {
                    response = new ResponseModel
                    {
                        Message = T("User_Message_UserDoesNotExist"),
                        Success = false
                    };
                }
            }
            catch (Exception exception)
            {
                response = new ResponseModel
                {
                    Success = false,
                    Message = exception.Message
                };
            }

            return(response);
        }
예제 #2
0
        public NavigationItemModel(FavouriteNavigation navigation)
            : this()
        {
            Id = navigation.NavigationId;
            var menu = _navigationService.GetById(navigation.NavigationId);

            if (menu != null)
            {
                Icon       = menu.Icon;
                Url        = menu.Url;
                Controller = menu.Controller;
                Action     = menu.Action;
                Name       = menu.Name;
                Hierarchy  = menu.Hierarchy;
                ParentId   = menu.ParentId;
            }
            Order = navigation.RecordOrder;
            IsFavouriteNavigation = true;
        }
예제 #3
0
 internal ResponseModel Delete(FavouriteNavigation favouriteNavigation)
 {
     return(_favouriteNavigationRepository.Delete(favouriteNavigation));
 }
예제 #4
0
 internal ResponseModel Insert(FavouriteNavigation favouriteNavigation)
 {
     return(_favouriteNavigationRepository.Insert(favouriteNavigation));
 }