コード例 #1
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("SystemAccount/Create/OnPostAsync");
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptySystemAccount = new SystemAccount();

            if (await TryUpdateModelAsync <SystemAccount>(
                    emptySystemAccount,
                    "systemaccount",                     // Preset for form value
                    s => s.UserName,
                    s => s.PassWord,
                    s => s.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.SystemAccount.Add(emptySystemAccount);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #2
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("Faxes/Create/OnPostAsync");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyFax = new Fax();

            if (await TryUpdateModelAsync <Fax>(
                    emptyFax,
                    "fax",                     // prefix for value
                    f => f.Number,
                    f => f.SerialNumber,
                    f => f.Pin,
                    f => f.Active,
                    f => f.Replace,
                    f => f.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.Fax.Add(emptyFax);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #3
0
ファイル: Edit.cshtml.cs プロジェクト: jmuelbert/jmbde-aspnet
        /// <summary>
        /// OnPostAsync
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"Inventories/Edit/OnPostAsync({ id })");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var inventoryToUpdate = await _context.Inventory.FindAsync(id).ConfigureAwait(false);

            if (await TryUpdateModelAsync <Inventory>(
                    inventoryToUpdate,
                    "inventory",                     // Prefix for form value
                    i => i.Identifier,
                    i => i.Description,
                    i => i.Active,
                    i => i.LastUpdate
                    ).ConfigureAwait(false))
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);

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

            return(Page());
        }
コード例 #4
0
        /// <summary>
        /// Ons the post async.
        /// </summary>
        /// <returns>The post async.</returns>
        /// <param name="id ">Identifier.</param>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"WorkFunctions/Delete/OnPostAsync({id})");

            if (id == null)
            {
                return(NotFound());
            }

            var workFunction = await _context.WorkFunction
                               .AsNoTracking()
                               .FirstOrDefaultAsync(f => f.ID == id).ConfigureAwait(false);

            if (workFunction == null)
            {
                return(NotFound());
            }

            try
            {
                _context.WorkFunction.Remove(workFunction);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index "));
            }
            catch (DbUpdateException ex)
            {
                _logger.LogError("Functions/Delete { 0 }", ex.ToString());

                return(RedirectToAction("./Delete ",
                                        new { id, saveChangesError = true }));
            }
        }
コード例 #5
0
        /// <summary>
        /// OnPostAsync
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"Phones/Edit/OnPostAsync({ id })");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var phoneToUpdate = await _context.Phone.FindAsync(id).ConfigureAwait(false);

            if (await TryUpdateModelAsync <Phone>(
                    phoneToUpdate,
                    "phone",                     // Preset for form value
                    p => p.Number,
                    p => p.SerialNumber,
                    p => p.Pin,
                    p => p.Active,
                    p => p.Replace,
                    p => p.LastUpdate
                    ).ConfigureAwait(false))
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);

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

            return(Page());
        }
コード例 #6
0
ファイル: Edit.cshtml.cs プロジェクト: jmuelbert/jmbde-aspnet
        /// <summary>
        /// OnPostAsync
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"Software/Edit/OnPostAsync({ id })");
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var softwareToUpdate = await _context.Software.FindAsync(id).ConfigureAwait(false);

            if (await TryUpdateModelAsync <Software>(
                    softwareToUpdate,
                    "software",                     // Preset for form value
                    s => s.Name,
                    s => s.Version,
                    s => s.Revision,
                    s => s.Fix,
                    s => s.LastUpdate
                    ).ConfigureAwait(false))
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);

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

            return(Page());
        }
コード例 #7
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("Processors/Create/OnPostAsync");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyProcessor = new Processor();

            if (await TryUpdateModelAsync <Processor>(
                    emptyProcessor,
                    "processor",                     // Preset for form value
                    p => p.Name,
                    p => p.ClockRate,
                    p => p.Cores,
                    p => p.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.Processor.Add(emptyProcessor);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #8
0
        /// <summary>
        /// Ons the post async.
        /// </summary>
        /// <returns>The post async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug($"ChipCard/Create/OnPostAsync");
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyChipCard = new ChipCard();

            if (await TryUpdateModelAsync <ChipCard>(
                    emptyChipCard,
                    "chipcard",                     // Prefix for form value.
                    c => c.Number,
                    c => c.Locked,
                    c => c.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.ChipCard.Add(emptyChipCard);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #9
0
        /// <summary>
        /// OnPostAsync
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"SystemAccount/Edit/OnPostAsync({ id })");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var systemaccountToUpdate = await _context.SystemAccount.FindAsync(id).ConfigureAwait(false);

            if (await TryUpdateModelAsync <SystemAccount>(
                    systemaccountToUpdate,
                    "systemaccount",                     // Preset for form value
                    s => s.UserName,
                    s => s.PassWord,
                    s => s.LastUpdate
                    ).ConfigureAwait(false))
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);

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

            return(Page());
        }
コード例 #10
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("ZipCodes/Create/OnPostAsync");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyZipCode = new ZipCode();

            if (await TryUpdateModelAsync <ZipCode>(
                    emptyZipCode,
                    "zipcode",                     // Preset for form value
                    z => z.Code,
                    z => z.Country,
                    z => z.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.ZipCode.Add(emptyZipCode);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #11
0
        /// <summary>
        /// OnPostAsync
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"ChipCardDoors/Edit/OnPostAsync({ id })");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var chipcarddoorToUpdate = await _context.ChipCardDoor.FindAsync(id).ConfigureAwait(false);

            if (await TryUpdateModelAsync <ChipCardDoor>(
                    chipcarddoorToUpdate,
                    "chipcarddoor",
                    c => c.Number,
                    c => c.Place,
                    c => c.LastUpdate).ConfigureAwait(false))
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);

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

            return(Page());
        }
コード例 #12
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("Printers/Create/OnPostAsync");
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyPrinter = new Printer();

            if (await TryUpdateModelAsync <Printer>(
                    emptyPrinter,
                    "printer",                     // Preset for form value
                    p => p.Name,
                    p => p.SerialNumber,
                    p => p.ServiceTag,
                    p => p.ServiceNumber,
                    p => p.Network,
                    p => p.NetworkIpAddress,
                    p => p.Active,
                    p => p.Replace,
                    p => p.Resources,
                    p => p.Color,
                    p => p.PaperSize,
                    p => p.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.Printer.Add(emptyPrinter);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #13
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("CityNames/Create/OnPostAsync");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyCityName = new CityName();

            if (await TryUpdateModelAsync <CityName>(
                    emptyCityName,
                    "cityname",                     // Prefix for form value
                    c => c.Name,
                    c => c.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.CityName.Add(emptyCityName);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #14
0
        /// <summary>
        /// OnPostAsync
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"Companies/Edit/OnPostAsync{ id })");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var companyToUpdate = await _context.Company.FindAsync(id).ConfigureAwait(false);

            if (await TryUpdateModelAsync <Company>(
                    companyToUpdate,
                    "company",                     // Prefix for form value
                    c => c.Name,
                    c => c.Name2,
                    c => c.Street,
                    c => c.PhoneNumber,
                    c => c.FaxNumber,
                    c => c.MobileNumber,
                    c => c.MailAddress,
                    c => c.Active,
                    c => c.LastUpdate
                    ).ConfigureAwait(false))
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(Page());
        }
コード例 #15
0
        /// <summary>
        /// Ons the post async.
        /// </summary>
        /// <returns>The post async.</returns>
        /// <param name="id ">Identifier.</param>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"ChipCards/Delete/OnPostAsync  { id }");

            if (id == null)
            {
                return(NotFound());
            }

            var chipcard = await _context.ChipCard
                           .AsNoTracking()
                           .FirstOrDefaultAsync(c => c.ID
                                                == id)
                           .ConfigureAwait(false);

            if (chipcard == null)
            {
                return(NotFound());
            }

            try
            {
                _context.ChipCard.Remove(chipcard);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index "));
            }
            catch (DbUpdateException ex)
            {
                _logger.LogError("ChipCards/Delete { 0 }", ex.ToString());
                return(RedirectToAction("./Delete ",
                                        new { id, saveChangesError = true }));
            }
        }
コード例 #16
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("Phones/Create/OnPostAsync");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyPhone = new Phone();

            if (await TryUpdateModelAsync <Phone>(
                    emptyPhone,
                    "phone",                     // Preset for form value
                    p => p.Number,
                    p => p.SerialNumber,
                    p => p.Pin,
                    p => p.Active,
                    p => p.Replace,
                    p => p.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.Phone.Add(emptyPhone);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #17
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("Manufacturers/Create/OnPostAsync");
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyManufacturer = new Manufacturer();

            if (await TryUpdateModelAsync <Manufacturer>(
                    emptyManufacturer,
                    "manufacturer",                     // Prefix for form value
                    m => m.Name,
                    m => m.Name2,
                    m => m.Supporter,
                    m => m.Street,
                    m => m.Street22,
                    m => m.MailAddress,
                    m => m.PhoneNumber,
                    m => m.FaxNumber,
                    m => m.HotlineNumber,
                    m => m.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.Manufacturer.Add(emptyManufacturer);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #18
0
ファイル: Edit.cshtml.cs プロジェクト: jmuelbert/jmbde-aspnet
        /// <summary>
        /// OnPostAsync
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"Faxes/Edit/OnPostAsync({ id })");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var faxToUpdate = await _context.Fax.FindAsync(id).ConfigureAwait(false);

            if (await TryUpdateModelAsync <Fax>(
                    faxToUpdate,
                    "fax",                     // prefix for value
                    f => f.Number,
                    f => f.SerialNumber,
                    f => f.Pin,
                    f => f.Active,
                    f => f.Replace,
                    f => f.LastUpdate
                    ).ConfigureAwait(false))
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);

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

            return(Page());
        }
コード例 #19
0
        /// <summary>
        /// OnPostAsync
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"Printers/Edit/OnPostAsync({ id })");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var printerToUpdate = await _context.Printer.FindAsync(id).ConfigureAwait(false);

            if (await TryUpdateModelAsync <Printer>(
                    printerToUpdate,
                    "printer",                     // Preset for form value
                    p => p.Name,
                    p => p.SerialNumber,
                    p => p.ServiceTag,
                    p => p.ServiceNumber,
                    p => p.Network,
                    p => p.NetworkIpAddress,
                    p => p.Active,
                    p => p.Replace,
                    p => p.Resources,
                    p => p.Color,
                    p => p.PaperSize,
                    p => p.LastUpdate
                    ).ConfigureAwait(false))
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);

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

            return(Page());
        }
コード例 #20
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("Software/Create/OnPostAsync");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptySoftware = new Software();

            if (await TryUpdateModelAsync <Software>(
                    emptySoftware,
                    "software",                     // Preset for form value
                    s => s.Name,
                    s => s.Version,
                    s => s.Revision,
                    s => s.Fix,
                    s => s.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.Software.Add(emptySoftware);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #21
0
ファイル: Edit.cshtml.cs プロジェクト: jmuelbert/jmbde-aspnet
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        /// <param name="id">Identifier.</param>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"ZipCodes/Edit/OnPostAsync({ id })");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var zipcodeToUpdate = await _context.ZipCode.FindAsync(id).ConfigureAwait(false);

            if (await TryUpdateModelAsync <ZipCode>(
                    zipcodeToUpdate,
                    "zipcode",                     // Preset for form value
                    z => z.Code,
                    z => z.Country,
                    z => z.LastUpdate
                    ).ConfigureAwait(false))
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);

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

            return(Page());
        }
コード例 #22
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("JobTitles/Create/OnPostAsync");
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyJobTitle = new JobTitle();

            if (await TryUpdateModelAsync <JobTitle>(
                    emptyJobTitle,
                    "jobtitle",                     // Prefix for form value
                    j => j.Name,
                    j => j.FromDate,
                    j => j.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.JobTitle.Add(emptyJobTitle);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #23
0
        /// <summary>
        /// OnPostAsync
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>

        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"Processors/Edit/OnPostAsync({ id })");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var processorToUpdate = await _context.Processor.FindAsync(id).ConfigureAwait(false);

            if (await TryUpdateModelAsync <Processor>(
                    processorToUpdate,
                    "processor",                     // Preset for form value
                    p => p.Name,
                    p => p.ClockRate,
                    p => p.Cores,
                    p => p.LastUpdate
                    ).ConfigureAwait(false))
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);

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

            return(Page());
        }
コード例 #24
0
ファイル: Edit.cshtml.cs プロジェクト: jmuelbert/jmbde-aspnet
        /// <summary>
        /// OnPostAsync
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug("DeviceName/Edit/OnPostAsync({ id })");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var devicenameToUpdate = await _context.DeviceName.FindAsync(id).ConfigureAwait(false);

            if (await TryUpdateModelAsync <DeviceName>(
                    devicenameToUpdate,
                    "devicename",                     // Prefix for form value
                    d => d.Name,
                    d => d.LastUpdate
                    ).ConfigureAwait(false))
            {
                await _context.SaveChangesAsync().ConfigureAwait(false);

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

            return(Page());
        }
コード例 #25
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("Places/Create/OnPostAsync");
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyPlace = new Place();

            if (await TryUpdateModelAsync <Place>(
                    emptyPlace,
                    "place",                     // Preset for form value
                    p => p.Name,
                    p => p.Room,
                    p => p.Desk,
                    p => p.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.Place.Add(emptyPlace);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #26
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("Companies/Create/OnPostAsync");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyCompany = new Company();

            if (await TryUpdateModelAsync <Company>(
                    emptyCompany,
                    "company",                     // Prefix for form value
                    c => c.Name,
                    c => c.Name2,
                    c => c.Street,
                    c => c.PhoneNumber,
                    c => c.FaxNumber,
                    c => c.MobileNumber,
                    c => c.MailAddress,
                    c => c.Active,
                    c => c.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.Company.Add(emptyCompany);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #27
0
        /// <summary>
        /// Ons the get async.
        /// </summary>
        /// <returns>The get async.</returns>
        public async Task <IActionResult> OnPostAsync()
        {
            _logger.LogDebug("Mobiles/Create/OnPostAsync");

            if (!ModelState.IsValid)
            {
                return(Page());
            }

            var emptyMobile = new Mobile();

            if (await TryUpdateModelAsync <Mobile>(
                    emptyMobile,
                    "mobile",                     // Prefix for form value
                    m => m.Number,
                    m => m.SerialNumber,
                    m => m.Pin,
                    m => m.CardNumber,
                    m => m.Active,
                    m => m.Replace,
                    m => m.LastUpdate
                    ).ConfigureAwait(false))
            {
                _context.Mobile.Add(emptyMobile);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            return(null);
        }
コード例 #28
0
        /// <summary>
        /// Ons the post async.
        /// </summary>
        /// <returns>The post async.</returns>
        /// <param name="id">Identifier.</param>
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            _logger.LogDebug($"SystemAccount/Delete/OnPostAsync({ id })");
            if (id == null)
            {
                return(NotFound());
            }

            var systemaccount = await _context.SystemAccount
                                .AsNoTracking()
                                .SingleOrDefaultAsync(s => s.ID == id).ConfigureAwait(false);

            if (systemaccount == null)
            {
                return(NotFound());
            }

            try
            {
                _context.SystemAccount.Remove(systemaccount);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            catch (DbUpdateException ex)
            {
                _logger.LogError("SystemAccount/Delete {0}", ex.ToString());

                return(RedirectToAction("./Delete",
                                        new { id, saveChangesError = true }));
            }
        }
コード例 #29
0
        /// <summary>
        /// Ons the post async.
        /// </summary>
        /// <returns>The post async.</returns>
        /// <param name="id">Identifier.</param>
        public async Task <IActionResult> OnPostAsync(long?id)
        {
            _logger.LogDebug($"Documents/Delete/OnPostAsync ({ id })");

            if (id == null)
            {
                return(NotFound());
            }

            var document = await _context.Document
                           .AsNoTracking()
                           .FirstOrDefaultAsync(d => d.ID == id).ConfigureAwait(false);

            if (document == null)
            {
                return(NotFound());
            }

            try
            {
                _context.Document.Remove(document);
                await _context.SaveChangesAsync().ConfigureAwait(false);

                return(RedirectToPage("./Index"));
            }
            catch (DbUpdateException ex)
            {
                _logger.LogError("Documents/Delete {0}", ex.ToString());

                return(RedirectToAction("./Delete",
                                        new { id, saveChangesError = true }));
            }
        }
コード例 #30
0
ファイル: Edit.cshtml.cs プロジェクト: jmuelbert/jmbde-aspnet
		/// <summary>
		/// OnPostAsync
		/// </summary>
		/// <param name="id"></param>
		/// <returns></returns>
		public async Task<IActionResult> OnPostAsync(int? id)
		{
			_logger.LogDebug($"JobTitles/Edit/OnPostAsync({ id })");

			if (!ModelState.IsValid)
			{
				return Page();
			}

			var jobtitleToUpdate = await _context.JobTitle.FindAsync(id).ConfigureAwait(false);

			if (await TryUpdateModelAsync<JobTitle>(
					jobtitleToUpdate,
					"jobtitle", // Prefix for form value
					j => j.Name,
					j => j.FromDate,
					j => j.LastUpdate
				).ConfigureAwait(false))
			{
				await _context.SaveChangesAsync().ConfigureAwait(false);
				return RedirectToPage("./Index");
			}

			return Page();
		}