示例#1
0
        public async Task <IActionResult> Create(int currencyId, [Bind("Id,Price,DateCreation,CurrencyId")] Prices prices)
        {
            prices.DateCreation = DateTime.Now;
            prices.CurrencyId   = currencyId;
            Console.WriteLine("IDDDD : " + prices.Id);
            if (ModelState.IsValid)
            {
                _context.Add(prices);
                await _context.SaveChangesAsync();

                //return RedirectToAction(nameof(Index));
                return(RedirectToAction("Index", "Prices", new
                {
                    id = currencyId,
                    currency = _context.Currencys
                               .Where(c => c.Id == currencyId)
                               .FirstOrDefault().Currency
                }));
            }
            //ViewData["CurrencyId"] = new SelectList(_context.Currencys, "Id", "Id", prices.CurrencyId);
            return(RedirectToAction("Index", "Prices", new
            {
                id = currencyId,
                currency = _context.Currencys
                           .Where(c => c.Id == currencyId)
                           .FirstOrDefault().Currency
            }));
        }
        public async Task <IActionResult> Create([Bind("Id,Manufacturer")] Manufacturers manufacturers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(manufacturers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(manufacturers));
        }
示例#3
0
        public async Task <IActionResult> Create([Bind("Id,TypePacking")] TypesPackings typesPackings)
        {
            if (ModelState.IsValid)
            {
                _context.Add(typesPackings);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(typesPackings));
        }
示例#4
0
        public async Task <IActionResult> Create([Bind("Id,Currency")] Currencys currencys)
        {
            if (ModelState.IsValid)
            {
                _context.Add(currencys);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(currencys));
        }
示例#5
0
        public async Task <IActionResult> Create([Bind("Id,ClassificationPerfume")] ClassificationsPerfumes classificationsPerfumes)
        {
            if (ModelState.IsValid)
            {
                _context.Add(classificationsPerfumes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(classificationsPerfumes));
        }
示例#6
0
        public async Task <IActionResult> Create(int id, string check, [Bind("PackingId,PriceId")] Perfumes perfumes)
        {
            Console.WriteLine("check : " + check);
            Console.WriteLine("PackingId : " + perfumes.PackingId);
            Console.WriteLine("PriceId : " + perfumes.PriceId);
            Console.WriteLine("Id : " + perfumes.Id);
            if (check == "price")
            {
                perfumes.PriceId = id;
                if (ModelState.IsValid)
                {
                    _context.Add(perfumes);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "Perfumes", new
                    {
                        priceId = perfumes.PriceId,
                        price = _context.Prices
                                .Where(c => c.Id == perfumes.PriceId)
                                .FirstOrDefault().Price
                    }));
                }
            }
            if (check == "packing")
            {
                perfumes.PackingId = id;

                if (ModelState.IsValid)
                {
                    _context.Add(perfumes);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "Perfumes", new
                    {
                        packingId = perfumes.PackingId,
                        volume = _context.Packings
                                 .Where(c => c.Id == perfumes.PackingId)
                                 .FirstOrDefault().Volume
                    }));
                }
            }

            if (ModelState.IsValid)
            {
                _context.Add(perfumes);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PackingId"] = new SelectList(_context.Perfumes, "Id", "Volume", perfumes.PackingId);
            ViewData["PriceId"]   = new SelectList(_context.Perfumes, "Id", "Price", perfumes.PriceId);
            return(View(perfumes));
        }
        public async Task <IActionResult> Create(
            int id,
            string check,
            [Bind("Id,YearOfIssue,ClassificationPerfumeId,ManufacturerId,PicturePath,PerfumeName")] PerfumesInformations perfumesInformations)
        {
            Console.WriteLine("check : " + check);
            Console.WriteLine("YearOfIssue : " + perfumesInformations.YearOfIssue);
            Console.WriteLine("PicturePath : " + perfumesInformations.PicturePath);
            Console.WriteLine("PerfumeName : " + perfumesInformations.PerfumeName);
            Console.WriteLine("ManufacturerId : " + perfumesInformations.ManufacturerId);
            Console.WriteLine("ClassificationPerfumeId : " + perfumesInformations.ClassificationPerfumeId);
            Console.WriteLine("Id : " + id);
            if (check == "manufacturer")
            {
                perfumesInformations.ManufacturerId = id;
                if (ModelState.IsValid)
                {
                    _context.Add(perfumesInformations);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "PerfumesInformations", new
                    {
                        manufacturerId = perfumesInformations.ManufacturerId,
                        manufacturer = _context.Manufacturers
                                       .Where(c => c.Id == perfumesInformations.ManufacturerId)
                                       .FirstOrDefault().Manufacturer
                    }));
                }
            }
            if (check == "classificationsPerfume")
            {
                perfumesInformations.ClassificationPerfumeId = id;
                if (ModelState.IsValid)
                {
                    _context.Add(perfumesInformations);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "PerfumesInformations", new
                    {
                        classificationsPerfumeId = perfumesInformations.ClassificationPerfumeId,
                        classificationsPerfume = _context.ClassificationsPerfumes
                                                 .Where(c => c.Id == perfumesInformations.ClassificationPerfumeId)
                                                 .FirstOrDefault().ClassificationPerfume
                    }));
                }
            }

            ViewData["ClassificationPerfumeId"] = new SelectList(_context.ClassificationsPerfumes, "Id", "ClassificationPerfume", perfumesInformations.ClassificationPerfumeId);
            ViewData["ManufacturerId"]          = new SelectList(_context.Manufacturers, "Id", "Manufacturer", perfumesInformations.ManufacturerId);
            return(View(perfumesInformations));
        }
示例#8
0
        public async Task <IActionResult> Create(
            int id,
            string check,
            [Bind("TypePackingId,Volume,PerfumeInformationId")] Packings packings)
        {
            if (check == "typesPacking")
            {
                packings.TypePackingId = id;
                if (ModelState.IsValid)
                {
                    _context.Add(packings);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "Packings", new
                    {
                        typesPackingId = packings.TypePackingId,
                        typesPacking = _context.TypesPackings
                                       .Where(c => c.Id == packings.TypePackingId)
                                       .FirstOrDefault().TypePacking
                    }));
                }
            }

            if (check == "perfumeInformation")
            {
                packings.PerfumeInformationId = id;
                if (ModelState.IsValid)
                {
                    _context.Add(packings);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction("Index", "Packings", new
                    {
                        perfumeInformationId = packings.PerfumeInformationId,
                        perfumeName = _context.PerfumesInformations
                                      .Where(c => c.Id == packings.PerfumeInformationId)
                                      .FirstOrDefault().PerfumeName
                    }));
                }
            }
            if (ModelState.IsValid)
            {
                _context.Add(packings);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PerfumeInformationId"] = new SelectList(_context.PerfumesInformations, "Id", "Id", packings.PerfumeInformationId);
            ViewData["TypePackingId"]        = new SelectList(_context.TypesPackings, "Id", "Id", packings.TypePackingId);
            return(View(packings));
        }