public async Task <IActionResult> UnclaimProduct(int id)
        {
            var receiver = await membersService.GetUser(HttpContext.User);

            var isUnClaimed = await receiversService.UnclaimProduct(id, receiver.Id);

            return(RedirectToAction(nameof(Cart)));
        }
        public async Task <IActionResult> CheckoutAsync()
        {
            var User = await mService.GetUser();

            CheckoutVM input;

            if (User != null)
            {
                input = new CheckoutVM
                {
                    Id        = User.Id,
                    FirstName = User.FirstName,
                    LastName  = User.LastName,
                    Email     = User.Email,
                    Street    = User.Street,
                    Zip       = User.Zip,
                    City      = User.City,
                    OrderCart = await pService.GetSummaryVMAsync()
                };
            }
            else
            {
                input = new CheckoutVM
                {
                    OrderCart = await pService.GetSummaryVMAsync()
                };
            };

            return(View(input));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> AddProduct(GiversAddProductVM giversAddProductVM)
        {
            if (!ModelState.IsValid)
            {
                return(View(giversAddProductVM));
            }

            if (giversAddProductVM.Picture != null)
            {
                var uniqueFileName = Helper.GetUniqueFileName(giversAddProductVM.Picture.FileName);
                var images         = Path.Combine(hostingEnvironment.WebRootPath, "products");
                var filePath       = Path.Combine(images, uniqueFileName);
                giversAddProductVM.Picture.CopyTo(new FileStream(filePath, FileMode.Create));
                giversAddProductVM.PictureFileName = uniqueFileName;
            }

            if (giversAddProductVM.Link != null)
            {
                var uniqueFileName = Helper.GetUniqueFileName(giversAddProductVM.Link);
                //fileName = fileService.GetFileName(viewModel.ImageUrl);
                var fileName = fileService.GetFileName(giversAddProductVM.Link);

                await fileService.SaveFileFromUrlAsync(giversAddProductVM.Link, fileName);

                giversAddProductVM.PictureFileName = fileName;
            }

            var giver = await membersService.GetUser(HttpContext.User);

            giversAddProductVM.GiverId = giver.Id;
            giversAddProductVM.Street  = giver.Street;
            giversAddProductVM.City    = giver.City;
            giversAddProductVM.ZipCode = giver.ZipCode;


            var location = await giversService.GetCoordinates(giver);

            giversAddProductVM.Location = location;

            await giversService.CreateProductAsync(giversAddProductVM);

            return(RedirectToAction(nameof(AddProduct)));
        }
Exemplo n.º 4
0
        public async Task SendMessage(int productId, string giverId, string receiverId, string sentById, string sendMessage)
        {
            await messagesService.AddMessage(new MessagesChatVM {
                ProductId   = productId,
                GiverId     = giverId,
                ReceiverId  = receiverId,
                SentById    = sentById,
                SendMessage = sendMessage
            });

            var member = await membersService.GetUser(sentById);

            var user   = Context.GetHttpContext().User;
            var userId = membersService.GetUserId(user);
            await Clients.All.SendAsync("ReceiveMessage", member.Picture, member.FirstName, DateTime.Now, sendMessage, sentById == userId);
        }