public async Task <IActionResult> Create(ProductProdactionViewModel productProdactionViewModel)
        {
            DayProduction dayProduction = _context.DayProductions.Where(d => d.Date.Equals(productProdactionViewModel.Date)).FirstOrDefault();

            if (dayProduction == null)
            {
                _context.DayProductions.Add(new DayProduction {
                    Date = productProdactionViewModel.Date
                });
                await _context.SaveChangesAsync();

                dayProduction = _context.DayProductions.Where(d => d.Date.Equals(productProdactionViewModel.Date)).FirstOrDefault();
            }
            ProductsProduction productsProduction = productProdactionViewModel.ProductsProduction;

            productsProduction.DayProductionId = dayProduction.DayProductionId;
            _context.Add(productsProduction);
            await _context.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
        public async Task <IActionResult> Edit(int id, ProductProdactionViewModel productProdactionViewModel)
        {
            if (id != productProdactionViewModel.ProductsProduction.ProductProductionId)
            {
                return(NotFound());
            }
            DayProduction dayProduction = _context.DayProductions.Where(d => d.Date.Equals(productProdactionViewModel.Date)).FirstOrDefault();

            if (dayProduction == null)
            {
                _context.DayProductions.Add(new DayProduction {
                    Date = productProdactionViewModel.Date
                });
                await _context.SaveChangesAsync();

                dayProduction = _context.DayProductions.Where(d => d.Date.Equals(productProdactionViewModel.Date)).FirstOrDefault();
            }
            ProductsProduction productsProduction = productProdactionViewModel.ProductsProduction;

            productsProduction.DayProductionId = dayProduction.DayProductionId;
            try
            {
                _context.Update(productsProduction);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductsProductionExists(productsProduction.ProductProductionId))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(RedirectToAction("Index"));
        }