Ejemplo n.º 1
0
        public ActionResult Details(int id)
        {
            var laptop    = this.Db.LaptopsRepository.GetById(id);
            var viewModel = new LaptopDetailsViewModel()
            {
                AdditionalParts = laptop.AdditionalParts,
                ImageUrl        = laptop.ImageUrl,
                Manufacturer    = laptop.Manufacturer.Name,
                Model           = laptop.Model,
                Price           = laptop.Price,
                Id       = laptop.Id,
                Comments = laptop.Comments.Select(x => new CommentViewModel()
                {
                    Author  = x.Author.UserName,
                    Content = x.Content
                }).ToList(),
                Description   = laptop.Description,
                HardDiskSize  = laptop.HardDiskSize,
                MonitorSize   = laptop.MonitorSize,
                RamMemorySize = laptop.RamMemorySize,
                Weight        = laptop.Weight,
                Votes         = laptop.Votes.Count(),
                UserCanVote   = laptop.Votes.All(vote => vote.VotedById != this.User.Identity.GetUserId()),
            };

            return(View(viewModel));
        }
Ejemplo n.º 2
0
        public string AddLaptop(LaptopDetailsViewModel Specyfication, string ProductName, string CodeProduct, int CategoryID, string OldPriceN, string PriceN, string VAT, string Description, int Quantity, bool Recommended, bool IsShowed)
        {
            string  answer = "";
            decimal parseOldPriceN;
            decimal parsePriceN;
            decimal parseVAT;

            answer = ProductManager.CheckDetailsProduct(ProductName, CodeProduct, CategoryID, OldPriceN, PriceN, VAT, Description, Quantity, Recommended, IsShowed, out parseOldPriceN, out parsePriceN, out parseVAT);
            if (!string.IsNullOrWhiteSpace(answer))
            {
                return(answer);
            }

            ProductViewModel product = new ProductViewModel
            {
                Name        = ProductName,
                CodeProduct = CodeProduct,
                CategoryID  = CategoryID,
                OldPriceN   = parseOldPriceN,
                PriceN      = parsePriceN,
                VAT         = parseVAT,
                Description = Description,
                Quantity    = Quantity,
                Recommended = Recommended,
                IsShowed    = IsShowed
            };

            if (ProductManager.CheckProductExistsName(ProductName))
            {
                return("-1");
            }
            ProductManager.AddLaptop(Specyfication, product);
            TempData["Message"] = "Dodano produkt";
            return(ProductManager.GetNameCategoryAndProductID(product.Name));
        }