예제 #1
0
 /// <summary>
 /// Gets all payments
 /// </summary>
 /// <returns>DTO of payments</returns>
 public AlzaAdminDTO <List <Payment> > GetPayments()
 {
     try
     {
         var payments = _paymentRepository.GetPayments().ToList();
         return(AlzaAdminDTO <List <Payment> > .Data(payments));
     }
     catch (Exception e)
     {
         return(AlzaAdminDTO <List <Payment> > .Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #2
0
 /// <summary>
 /// Gets all shippings
 /// </summary>
 /// <returns>Shippings</returns>
 public AlzaAdminDTO <List <Shipping> > GetShippings()
 {
     try
     {
         var shippings = _shippingRepository.GetShippings().ToList();
         return(AlzaAdminDTO <List <Shipping> > .Data(shippings));
     }
     catch (Exception e)
     {
         return(AlzaAdminDTO <List <Shipping> > .Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #3
0
 /// <summary>
 /// Gets a payment by id
 /// </summary>
 /// <param name="id">Payment id</param>
 /// <returns>DTO of the payment</returns>
 public AlzaAdminDTO <Payment> GetPayment(int id)
 {
     try
     {
         var payment = _paymentRepository.GetPayment(id);
         return(AlzaAdminDTO <Payment> .Data(payment));
     }
     catch (Exception e)
     {
         return(AlzaAdminDTO <Payment> .Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #4
0
 /// <summary>
 /// Gets a shipping by id
 /// </summary>
 /// <param name="id">Shipping id</param>
 /// <returns>DTO of the shipping</returns>
 public AlzaAdminDTO <Shipping> GetShipping(int id)
 {
     try
     {
         var shipping = _shippingRepository.GetShipping(id);
         return(AlzaAdminDTO <Shipping> .Data(shipping));
     }
     catch (Exception e)
     {
         return(AlzaAdminDTO <Shipping> .Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #5
0
 public AlzaAdminDTO GetMedia(int id)
 {
     try
     {
         var result = _mediaRepo.Get(id);
         return(AlzaAdminDTO.Data(result));
     }
     catch (Exception e)
     {
         return(Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #6
0
        /****************************************/
        /*         GET COUNTRY BY ID            */
        /****************************************/

        /// <summary>
        /// Provides a country with a specified id
        /// </summary>
        /// <param name="id">Country id</param>
        /// <returns>DTO containing the country with matching id</returns>
        public AlzaAdminDTO <Country> GetCountry(int id)
        {
            try
            {
                var result = _countryRepos.GetCountry(id);
                return(AlzaAdminDTO <Country> .Data(result));
            }
            catch (Exception e)
            {
                return(AlzaAdminDTO <Country> .Error(e.Message + Environment.NewLine + e.StackTrace));
            }
        }
예제 #7
0
 public AlzaAdminDTO AddMedia(Media item)
 {
     try
     {
         _mediaRepo.Add(item);
         return(AlzaAdminDTO.Data(item));
     }
     catch (Exception e)
     {
         return(Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #8
0
 /// <summary>
 /// Gets all front page presets marked as active.
 /// </summary>
 /// <returns>DTO of active Front page items</returns>
 public AlzaAdminDTO <List <FrontPageItem> > GetActivePageItems()
 {
     try
     {
         var result = _frontPageRepository.GetFrontPageItems().Where(fi => fi.Active == true).ToList();
         return(AlzaAdminDTO <List <FrontPageItem> > .Data(result));
     }
     catch (Exception e)
     {
         return(AlzaAdminDTO <List <FrontPageItem> > .Error(e.Message));
     }
 }
예제 #9
0
 /// <summary>
 /// Adds a new order item
 /// </summary>
 /// <param name="item">Item to be added</param>
 /// <returns>DTO of the order item</returns>
 public AlzaAdminDTO <OrderItem> AddOrderItem(OrderItem item)
 {
     try
     {
         var orderItem = _orderItemRepository.AddOrderItem(item);
         return(AlzaAdminDTO <OrderItem> .Data(orderItem));
     }
     catch (Exception e)
     {
         return(AlzaAdminDTO <OrderItem> .Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #10
0
 /**********************************************/
 /*              UPDATE ITEM                      */
 /**********************************************/
 public AlzaAdminDTO UpdateUserProfile(Dal.Entities.UserProfile item)
 {
     try
     {
         _userProfileRepo.Update(item);
         return(AlzaAdminDTO.Data(item));
     }
     catch (Exception e)
     {
         return(Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #11
0
 /**********************************************/
 /*              UPDATE ITEM                      */
 /**********************************************/
 public AlzaAdminDTO UpdateProduct(Product item)
 {
     try
     {
         _productRepo.Update(item);
         return(AlzaAdminDTO.Data(item));
     }
     catch (Exception e)
     {
         return(Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #12
0
 public AlzaAdminDTO GetProductByCode(string code)
 {
     try
     {
         var result = _productRepo.GetByCode(code);
         return(AlzaAdminDTO.Data(result));
     }
     catch (Exception e)
     {
         return(Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #13
0
 public AlzaAdminDTO GetCategoryBySEOName(string seoName)
 {
     try
     {
         var result = _categoryRepo.GetBySEOName(seoName);
         return(AlzaAdminDTO.Data(result));
     }
     catch (Exception e)
     {
         return(Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #14
0
        /// <summary>
        /// HELPER return and log error
        /// </summary>
        /// <param name="text"></param>
        /// <returns></returns>
        public AlzaAdminDTO InvalidIdentityResultDTO(IdentityResult result)
        {
            Guid          errNo = Guid.NewGuid();
            StringBuilder res   = new StringBuilder();

            foreach (var error in result.Errors)
            {
                res.AppendLine(error.Description);
            }

            _logger.LogError(errNo + " - " + res.ToString());
            return(AlzaAdminDTO.Error(errNo, res.ToString()));
        }
예제 #15
0
        public AlzaAdminDTO InvalidModel()
        {
            AlzaAdminDTO invalidresult = AlzaAdminDTO.False;

            foreach (var item in ModelState.ToList())
            {
                foreach (var item2 in item.Value.Errors)
                {
                    invalidresult.errors.Add(item.Key + " - " + item2.ErrorMessage);
                }
            }
            return(invalidresult);
        }
예제 #16
0
        /// <summary>
        /// Full - GAMES collection
        /// </summary>
        /// <returns></returns>
        public AlzaAdminDTO GetGames()
        {
            try
            {
                var result = _mediaRepo.Query("Game").ToList();

                return(AlzaAdminDTO.Data(result));
            }
            catch (Exception e)
            {
                return(Error(e.Message + Environment.NewLine + e.StackTrace));
            }
        }
예제 #17
0
        public AlzaAdminDTO GetCategories()
        {
            try
            {
                var result = _categoryRepo.Query().ToList().Where(c => c.ParentId != null).ToList();

                return(AlzaAdminDTO.Data(result));
            }
            catch (Exception e)
            {
                return(Error(e.Message + Environment.NewLine + e.StackTrace));
            }
        }
예제 #18
0
 /// <summary>
 /// Deletes an item from the cart.
 /// </summary>
 /// <param name="visitorId">Id of the item owner</param>
 /// <param name="productId">Product id</param>
 /// <returns>DTO of the cart</returns>
 public AlzaAdminDTO <List <CartItem> > RemoveCartItem(string visitorId, int productId)
 {
     try
     {
         _cartItemRepository.DeleteCartItem(visitorId, productId);
         var result = _cartItemRepository.GetCartItems().Where(ci => ci.VisitorId == visitorId).ToList();
         return(AlzaAdminDTO <List <CartItem> > .Data(result));
     }
     catch (Exception e)
     {
         return(AlzaAdminDTO <List <CartItem> > .Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #19
0
        public AlzaAdminDTO GetGamesCount(string categoryName)
        {
            try
            {
                var result = _categoryRepo.GetStats1ByCategoryName(categoryName, "Game");

                return(AlzaAdminDTO.Data(result));
            }
            catch (Exception e)
            {
                return(Error(e.Message + Environment.NewLine + e.StackTrace));
            }
        }
예제 #20
0
        /****************************************/
        /*         GET ALL COUNTRIES            */
        /****************************************/

        /// <summary>
        /// Provides a list of all countries
        /// </summary>
        /// <returns>DTO containing a list of all available countries</returns>
        public AlzaAdminDTO <ICollection <Country> > GetAllCountries()
        {
            try
            {
                var result = _countryRepos.GetCountries().ToList();

                return(AlzaAdminDTO <ICollection <Country> > .Data(result));
            }
            catch (Exception e)
            {
                return(AlzaAdminDTO <ICollection <Country> > .Error(e.Message + Environment.NewLine + e.StackTrace));
            }
        }
예제 #21
0
        //ToDo validate input data (UserProfile properties, index uniqueness,...)

        /****************************************/
        /*         GET USER PROFILE             */
        /****************************************/

        /// <summary>
        /// Provides a UserProfile in DTO.data whose Id property matches the id parameter.
        /// </summary>
        /// <param name="id">User id</param>
        /// <returns>Returns matching UserProfile in DTO data</returns>
        public AlzaAdminDTO <UserProfile> GetUserProfile(int id)
        {
            try
            {
                var result = _userRepos.GetProfile(id);

                return(AlzaAdminDTO <UserProfile> .Data(result));
            }
            catch (Exception e)
            {
                return(AlzaAdminDTO <UserProfile> .Error(e.Message + Environment.NewLine + e.StackTrace));
            }
        }
예제 #22
0
        /**********************************************/
        /*       GET  COLLECTIONS                     */
        /**********************************************/
        public AlzaAdminDTO GetUserProfiles()
        {
            try
            {
                var result = _userProfileRepo.Query().ToList();

                return(AlzaAdminDTO.Data(result));
            }
            catch (Exception e)
            {
                return(Error(e.Message + Environment.NewLine + e.StackTrace));
            }
        }
예제 #23
0
 /// <summary>
 /// Gets a review of a product by a specific user.
 /// </summary>
 /// <param name="userId">Id of the user who submitted the review</param>
 /// <param name="productId">Id of the reviewed product</param>
 /// <returns>DTO of the review</returns>
 public AlzaAdminDTO <Review> GetReview(int userId, int productId)
 {
     try
     {
         var result = _reviewRepository.GetReview(userId, productId);
         result.User = _userProfileRepository.GetProfile(result.UserId);
         return(AlzaAdminDTO <Review> .Data(result));
     }
     catch (Exception e)
     {
         return(AlzaAdminDTO <Review> .Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #24
0
        /// <summary>
        /// Gets a dictionary of indexed front page slots which contain front page items currently assigned to it.
        /// </summary>
        /// <returns>DTO of a dictionary containing all FrontPageSlots</returns>
        public AlzaAdminDTO <Dictionary <int, FrontPageSlot> > GetPageSlots()
        {
            try
            {
                var result = _frontPageRepository.GetSlotItems().ToDictionary(si => si.SlotId);

                return(AlzaAdminDTO <Dictionary <int, FrontPageSlot> > .Data(result));
            }
            catch (Exception e)
            {
                return(AlzaAdminDTO <Dictionary <int, FrontPageSlot> > .Error(e.Message));
            }
        }
예제 #25
0
        /// <summary>
        /// Merges an anonymous cart with an existing user cart. If there are any items in the user cart, it is possible to delete them or leave them intact.
        /// </summary>
        /// <param name="visitorId">Id of the visitor who owns the cart.</param>
        /// <param name="userId">Id of the user who should receive the visitor cart</param>
        /// <param name="delete">Specifies whether the old user cart items should be deleted or not</param>
        /// <returns>DTO of the merged cart</returns>
        public AlzaAdminDTO <List <CartItem> > TransformCart(string visitorId, int userId, bool delete)
        {
            try
            {
                //the old items should be deleted
                if (delete)
                {
                    var oldCartItems = _cartItemRepository.GetCartItems().Where(ci => ci.UserId == userId).ToList();
                    foreach (var item in oldCartItems)
                    {
                        _cartItemRepository.DeleteCartItem(item.VisitorId, item.ProductId);
                    }
                }

                //gets the visitor cart
                var currentCart = _cartItemRepository.GetCartItems().Where(ci => ci.VisitorId == visitorId).ToList();
                foreach (var item in currentCart)
                {
                    CartItem existingItem = null;

                    //if we want to keep the items, the amount might need to be updated for the same product
                    if (!delete)
                    {
                        existingItem = _cartItemRepository.GetCartItems().FirstOrDefault(ci => ci.UserId == userId && ci.ProductId == item.ProductId);
                    }
                    if (existingItem != null)
                    {
                        //adding the amounts
                        existingItem.Amount += item.Amount;
                        _cartItemRepository.UpdateCartItem(existingItem);
                    }
                    else
                    {
                        item.VisitorId = userId.ToString();
                        item.UserId    = userId;
                        _cartItemRepository.AddCartItem(item);
                    }

                    //the old cart needs to be deleted afterwards
                    _cartItemRepository.DeleteCartItem(visitorId, item.ProductId);
                }

                //the new cart
                var result = _cartItemRepository.GetCartItems().Where(ci => ci.UserId == userId).ToList();
                return(AlzaAdminDTO <List <CartItem> > .Data(result));
            }
            catch (Exception e)
            {
                return(AlzaAdminDTO <List <CartItem> > .Error(e.Message + Environment.NewLine + e.StackTrace));
            }
        }
예제 #26
0
        /// <summary>
        /// Gets a cart by user id
        /// </summary>
        /// <param name="userId">Id of the user</param>
        /// <returns>DTO of cart</returns>
        public AlzaAdminDTO <List <CartItem> > GetCart(int userId)
        {
            try
            {
                Expression <Func <CartItem, bool> > selector = ci => ci.UserId == userId;
                List <CartItem> completeCart = GetCartItems(selector);

                return(AlzaAdminDTO <List <CartItem> > .Data(completeCart));
            }
            catch (Exception e)
            {
                return(AlzaAdminDTO <List <CartItem> > .Error(e.Message + Environment.NewLine + e.StackTrace));
            }
        }
예제 #27
0
 /// <summary>
 /// Gets an order by id
 /// </summary>
 /// <param name="orderId">Id of the order</param>
 /// <returns>DTO of the order</returns>
 public AlzaAdminDTO <Order> GetOrder(int orderId)
 {
     try
     {
         var order = _orderRepository.GetOrder(orderId);
         //Might be slow-ish
         var products = _productRepository.GetAllProducts().Where(p => order.OrderItems.Select(oi => oi.ProductId).Contains(p.Id)).Select(p => new ProductBO(p, null, null));
         order.OrderItems = order.OrderItems.Join(products, oi => oi.ProductId, p => p.Id, (oi, p) => { oi.Product = p; return(oi); }).ToList();
         return(AlzaAdminDTO <Order> .Data(order));
     }
     catch (Exception e)
     {
         return(AlzaAdminDTO <Order> .Error(e.Message + Environment.NewLine + e.StackTrace));
     }
 }
예제 #28
0
        /****************************************/
        /*         ADD USER PROFILE             */
        /****************************************/

        /// <summary>
        /// Adds a UserProfile to the database
        /// </summary>
        /// <param name="userProfile">UserProfile to be added into the database</param>
        /// <returns>A DTO object containing the UserProfile in its Data property</returns>
        public AlzaAdminDTO <UserProfile> AddUserProfile(UserProfile userProfile)
        {
            try
            {
                if (!GetUserProfile(userProfile.Id).isEmpty)
                {
                    throw new Exception("User with the same id already exists.");
                }

                var result = _userRepos.AddUserProfile(userProfile);

                return(AlzaAdminDTO <UserProfile> .Data(result));
            }
            catch (Exception e)
            {
                return(AlzaAdminDTO <UserProfile> .Error(e.Message));
            }
        }
예제 #29
0
        /****************************************/
        /*      UPDATE USER PROFILE             */
        /****************************************/

        /// <summary>
        /// Updates a UserProfile
        /// </summary>
        /// <param name="profile">Updated User profile</param>
        /// <returns>Updated profile in DTO.data</returns>
        public AlzaAdminDTO <UserProfile> UpdateUserProfile(UserProfile profile)
        {
            try
            {
                if (GetUserProfile(profile.Id).isEmpty)
                {
                    throw new Exception("Invalid user id.");
                }


                var result = _userRepos.UpdateProfile(profile);
                return(AlzaAdminDTO <UserProfile> .Data(result));
            }
            catch (Exception e)
            {
                return(AlzaAdminDTO <UserProfile> .Error(e.Message));
            }
        }
예제 #30
0
        /// <summary>
        /// BY CATEGORY - GAMES collection
        /// </summary>
        /// <param name="categoryName"></param>
        /// <param name="pageNumber"></param>
        /// <param name="itemsPerPage"></param>
        /// <returns></returns>
        public AlzaAdminDTO GetGames(string categoryName)
        {
            try
            {
                var filter = new Dictionary <string, string>();
                filter.Add("@PageOffset", "0");
                filter.Add("@PageSize", "1000000");
                filter.Add("@MediaType", "Game");
                filter.Add("@CategoryName", categoryName);

                var result = _mediaRepo.Query(filter).ToList();
                return(AlzaAdminDTO.Data(result));
            }
            catch (Exception e)
            {
                return(Error(e.Message + Environment.NewLine + e.StackTrace));
            }
        }