public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WorldFleetExists(WorldFleet.Imo))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index", new { message = "Edit successful" }));
        }
        public async Task <IActionResult> OnPostAsync(uint?id)
        {
            if (id == null)
            {
                ModelState.AddModelError("CustomError", "There has been an error please try again");
            }

            try
            {
                WorldFleet = await _context.WorldFleet.FindAsync(id);

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

                return(RedirectToPage("./Index", new { message = "Vessel deleted" }));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("CustomError", e.InnerException.Message);
            }

            return(Page());
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                PopulateDropDowns();

                return(Page());
            }

            try
            {
                _context.WorldFleet.Add(WorldFleet);
                await _context.SaveChangesAsync();
            }
            catch (Exception e)
            {
                ModelState.AddModelError("CustomError", e.InnerException.Message);

                _logger.LogError(e.Message);

                PopulateDropDowns();

                return(Page());
            }


            return(RedirectToPage("./Index", new { message = "Vessel added" }));
        }
Exemple #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            return(RedirectToPage("./Index"));
        }
Exemple #5
0
        public async Task <IActionResult> OnPostAsync(string id)
        {
            if (id == null)
            {
                return(NotFound());
            }

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

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

            return(RedirectToPage("./Index", new { message = $"Entry {id} successfully deleted" }));
        }
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            Msd3.DataSourceId           = Msd3.DataSourceId;
            Msd3.ModifiedDate           = DateTime.Now;
            Msd3.LastUpdatedBy          = _userManager.GetUserName(HttpContext.User);
            _context.Attach(Msd3).State = EntityState.Modified;



            try
            {
                if (!Msd3ReportingPortExists(Msd3.ReportingPort))
                {
                    ModelState.AddModelError("CustomError", "There is a problem with the Reporting Port you have added");
                    return(Page());
                }
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Msd3Exists(Msd3.Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(RedirectToPage("./Index", new { message = "Submission succesfully updated" }));
        }