Exemplo n.º 1
0
        /// <summary>
        /// Get the current item's information and image to display
        /// </summary>
        /// <param name="id">Item ID</param>
        /// <returns>Page with item Name and ImgUrl bound to display to user</returns>
        public async Task OnGet(int id)
        {
            var item = await _inventory.GetFlummeryBy(id);

            Name          = item.Name;
            CurrentImgUrl = item.ImageUrl;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Add the imageURI to the flummery being updated
        /// </summary>
        /// <param name="flummeryId">Id of flummery to add image to</param>
        /// <param name="imageURI">Image URI to add to the flummery, stored in cloud storage</param>
        /// <returns>Task of completion of updated Flummery</returns>
        public async Task <Flummery> UpdateStoreDbFor(int flummeryId, string imageURI)
        {
            Flummery flummery = await _flummeryInventory.GetFlummeryBy(flummeryId);

            flummery.ImageUrl = imageURI;
            return(await _flummeryInventory.UpdateFlummery(flummery));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get a list of all the items in a user's card
        /// </summary>
        /// <param name="cartId">Unique id of card to find items from</param>
        /// <returns>Successful result with list of cartItems</returns>
        public async Task <List <CartItem> > GetUserCartItems(int cartId)
        {
            List <CartItem> items = await _context.CartItem.Where(x => x.CartId == cartId).ToListAsync();

            foreach (var item in items)
            {
                item.Product = await _flummery.GetFlummeryBy(item.ProductId);
            }
            return(items);
        }
        public async Task BuildRegistrationEmail(string emailAddress, string name)
        {
            string templateId = "d-d26e9bcbfef6438ab53fd65fca39da27";

            List <EmailItem> featuredFlums = new List <EmailItem>();
            List <int>       usedNums      = new List <int>();
            Random           rand          = new Random();

            for (int i = 0; i < 2; i++)
            {
                int temp = rand.Next(1, 10);
                while (usedNums.Contains(temp))
                {
                    temp = rand.Next(1, 10);
                }
                usedNums.Add(temp);
                Flummery flum = await _flummery.GetFlummeryBy(temp);

                featuredFlums.Add(new EmailItem {
                    Id        = flum.Id,
                    ImgSrc    = flum.ImageUrl,
                    ItemName  = flum.Name,
                    ItemPrice = flum.Price
                });
            }

            List <Personalization> personalizations = new List <Personalization>();

            personalizations.Add(new Personalization()
            {
                Tos = new List <EmailAddress>
                {
                    new EmailAddress(emailAddress)
                },
                Subject      = "Thanks for your purchase!",
                TemplateData = new RegistrationTemplateData()
                {
                    FullName     = name,
                    Date         = DateTime.Now.ToString(),
                    DisplayItems = featuredFlums
                }
            });
            await _email.SendEmail(templateId, personalizations);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get the specified flummeries information and display to the page, redirect to Products if it can't be found
        /// </summary>
        /// <param name="id">ID of flummery to edit</param>
        /// <returns>Page with the specified flummery info or redirection to Admin dash if it's not found</returns>
        public async Task <IActionResult> OnGet(int id)
        {
            Id = id;
            Flummery flum = await _flummery.GetFlummeryBy(id);

            if (flum != null)
            {
                Input = new ItemUploadViewModel
                {
                    Manufacturer = flum.Manufacturer,
                    Name         = flum.Name,
                    Calories     = flum.Calories,
                    Weight       = flum.Weight,
                    Price        = flum.Price,
                    Compliment   = flum.Compliment,
                };
                ImgUrl = flum.ImageUrl;
                return(Page());
            }
            return(RedirectToPage("/Admin/Index"));
        }