// To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            _context.Attach(TruckCargo).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TruckCargoExists(TruckCargo.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            WarehouseCargo = await _context.WarehouseCargo.FindAsync(id);

            if (WarehouseCargo != null)
            {
                _context.WarehouseCargo.Remove(WarehouseCargo);
                await _context.SaveChangesAsync();
            }

            return(RedirectToPage("./Index"));
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync()
        {
            // if (!ModelState.IsValid)
            // {
            int errors = 0;

            if (WarehouseCargo.WcargoName == "Wrong" || WarehouseCargo.WcargoName == "")
            {
                ErrorName = "Error in Name!";
                errors    = 1;
            }
            else if (WarehouseCargo.WcargoCount > 100 || WarehouseCargo.WcargoCount < 0)
            {
                ErrorCount = "Error in Count!";
                errors     = 1;
            }
            else if (WarehouseCargo.WcargoWeight <= 0 || WarehouseCargo.WcargoWeight > 50)
            {
                ErrorWeight = "Error in Weight!";
                errors      = 1;
            }
            else if (WarehouseCargo.WcargoOrigin == "Heaven" || WarehouseCargo.WcargoOrigin == "")
            {
                ErrorOrigin = "Error in Origin!";
                errors      = 1;
            }
            else if (WarehouseCargo.WcargoDestination == "Hell" || WarehouseCargo.WcargoDestination == "")
            {
                ErrorDestination = "Error in Destination!";
                errors           = 1;
            }

            // }
            if (errors == 1)
            {
                return(Page());
            }
            else if (errors == 0)
            {
                _context.WarehouseCargo.Add(WarehouseCargo);
                await _context.SaveChangesAsync();
            }
            return(RedirectToPage("./Index"));
        }