public ActionResult GetAccess(string id)
        {
            try
            {
                int[] parameters = UserCodeOperation.DecodeCode(id);

                int         cartId      = parameters[0];
                AccessLevel accessLevel = (AccessLevel)parameters[1];

                if (accessLevel == AccessLevel.Owner)
                {
                    throw new BusinessRuleException("Owner access level must not be selected");
                }

                User user = GetCurrentUser();

                CartOwner currentCartUser = CartOwnerService.Obj.GetCartUser(cartId, user.Id);

                if (currentCartUser != null)
                {
                    if (currentCartUser.AccessLevel == AccessLevel.Owner)
                    {
                        return(RedirectToAction("Index"));
                    }
                }

                FriendService.Obj.CreateFriends(user.Id, cartId);

                Cart cart = CartService.Obj.GetById(cartId);

                CartOwner cartOwner = CartOwner.Create(cart, user, accessLevel);

                CartOwnerService.Obj.Create(cartOwner);

                return(RedirectToAction("Index"));
            }

            catch (Exception ex)
            {
                TempData["ErrorMessage"] = ex.Message;

                return(RedirectToAction("Login", "Account"));
            }
        }
        public IHttpActionResult GetAccess([FromBody] GetAccessBindingModel model)
        {
            int[]       parameters  = UserCodeOperation.DecodeCode(model.Id);
            int         cartId      = parameters[0];
            AccessLevel accessLevel = (AccessLevel)parameters[1];

            User user = GetCurrentUser();

            FriendService.Obj.CreateFriends(user.Id, cartId);

            Cart cart = CartMobileService.Obj.GetById(cartId);

            CartOwner currentCartUser = CartOwnerMobileService.Obj.GetCartUser(cartId, user.Id);

            if (currentCartUser != null)
            {
                if (currentCartUser.AccessLevel == AccessLevel.Owner)
                {
                    CartIndexBindingModel earlyBindingModel = getCartIndexBindingModel(cart);

                    return(Ok(earlyBindingModel));
                }
            }

            CartOwner cartOwner = CartOwner.Create(cart, user, accessLevel);

            double cartIndex = CartOwnerMobileService.Obj.GetLastIndex(user.Id);

            cartOwner.SetCartIndex(cartIndex);

            CartOwnerMobileService.Obj.Create(cartOwner);

            CartIndexBindingModel bindingModel = getCartIndexBindingModel(cart);

            return(Ok(bindingModel));
        }