Exemple #1
0
        private async Task UpdateMig()
        {
            var migInDatabase = await _context.Migs
                                .Include(m => m.Modernizations)
                                .FirstOrDefaultAsync(m => m.SideNumber == Mig.SideNumber);

            migInDatabase.AirplaneId  = Mig.AirplaneId;
            migInDatabase.Notes       = Mig.Notes;
            migInDatabase.StagingArea = Mig.StagingArea;

            await _context.SaveChangesAsync();
        }
        public async Task <IActionResult> OnPostAsync()
        {
            CheckIfSideNumberUnique();
            if (!ModelState.IsValid)
            {
                return(OnGet());
            }

            _context.Migs.Add(Mig);
            await _context.SaveChangesAsync();

            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            CheckIfExistSuchModernization();
            CheckIfPerformed();

            if (!ModelState.IsValid)
            {
                return(OnGet(Modernization.MigSideNumber));
            }

            _context.Modernization.Add(Modernization);
            await _context.SaveChangesAsync();

            var routes = new RouteValueDictionary
            {
                { SideNumberParameterName, Modernization.MigSideNumber }
            };

            return(RedirectToPage("./Index", routes));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            CheckIfExistSuchModernization();
            CheckIfPerformed();
            if (!ModelState.IsValid)
            {
                return(await OnGetAsync(Modernization.Id));
            }

            var modernization = await _context.Modernization.FirstOrDefaultAsync(m => m.Id == Modernization.Id);

            modernization.ModernizationName = Modernization.ModernizationName;
            modernization.Performed         = Modernization.Performed;
            modernization.PlannedBy         = Modernization.PlannedBy;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ModernizationExists(Modernization.Id))
                {
                    return(NotFound());
                }
                else
                {
                    return(await OnGetAsync(Modernization.Id));
                }
            }

            var routes = new RouteValueDictionary
            {
                { SideNumberParameterName, Modernization.MigSideNumber }
            };

            return(RedirectToPage("./Index", routes));
        }