Exemple #1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //_context.Attach(Printer).State = EntityState.Modified;

            //try
            //{
            //    await _context.SaveChangesAsync();
            //}
            //catch (DbUpdateConcurrencyException)
            //{
            //    if (!PrinterExists(Printer.ID))
            //    {
            //        return NotFound();
            //    }
            //    else
            //    {
            //        throw;
            //    }
            //}

            var printerToUpdate = await _context.Printers.FindAsync(id);

            if (await TryUpdateModelAsync <Printer>(
                    printerToUpdate,
                    "Monitor",
                    c => c.UserLast,
                    c => c.UserFirst,
                    c => c.DepartmentID,
                    c => c.Department,
                    c => c.SerialNumber,
                    c => c.PurchasePrice,
                    c => c.AcquireDate,
                    c => c.Vendor,
                    c => c.Model,
                    c => c.LocationID,
                    c => c.LocationGeneric,
                    c => c.LocationSpecific,
                    c => c.RetireDate,
                    c => c.Comments,
                    c => c.Host,
                    c => c.IPAddress,
                    c => c.MAC,
                    c => c.CartridgeModel,
                    c => c.Make
                    ))
            {
                await _context.SaveChangesAsync();

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

            PopulateDepartmentsDropDownList(_context, Printer.DepartmentID);
            PopulateLocationsDropDownList(_context, Printer.LocationID);
            return(RedirectToPage("./Index"));
        }
Exemple #2
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LocationExists(Location.ID))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

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

            _context.Locations.Add(Location);
            await _context.SaveChangesAsync();

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

            _context.Monitors.Add(Monitor);
            await _context.SaveChangesAsync();

            PopulateDepartmentsDropDownList(_context, Monitor.DepartmentID);
            PopulateLocationsDropDownList(_context, Monitor.LocationID);
            return(RedirectToPage("./Index"));
        }
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            Computer = await _context.Computers.FindAsync(id);

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

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

            Location = await _context.Locations.FindAsync(id);

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

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

            Department = await _context.Departments.FindAsync(id);

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

            return(RedirectToPage("./Index"));
        }
Exemple #8
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (!ModelState.IsValid)
            {
                return(Page());
            }

            //_context.Attach(Computer).State = EntityState.Modified;

            //try
            //{
            //    await _context.SaveChangesAsync();
            //}
            //catch (DbUpdateConcurrencyException)
            //{
            //    if (!ComputerExists(Computer.ID))
            //    {
            //        return NotFound();
            //    }
            //    else
            //    {
            //        throw;
            //    }
            //}

            var computerToUpdate = await _context.Computers.FindAsync(id);

            if (await TryUpdateModelAsync <Computer>(
                    computerToUpdate,
                    "Computer",
                    c => c.UserLast,
                    c => c.UserFirst,
                    c => c.DepartmentID,
                    c => c.Department,
                    c => c.SerialNumber,
                    c => c.PurchasePrice,
                    c => c.AcquireDate,
                    c => c.Vendor,
                    c => c.Model,
                    c => c.LocationID,
                    c => c.LocationGeneric,
                    c => c.LocationSpecific,
                    c => c.RetireDate,
                    c => c.Comments,
                    c => c.Host,
                    c => c.Office,
                    c => c.IPAddress,
                    c => c.WirelessMAC,
                    c => c.MAC,
                    c => c.Domain,
                    c => c.Phone,
                    c => c.TypeID,
                    c => c.DeviceType,
                    c => c.OperatingSystem,
                    c => c.Processor,
                    c => c.ProcessorSpeed,
                    c => c.RAMSize,
                    c => c.RAMType,
                    c => c.RAMSpeed,
                    c => c.HDSize,
                    c => c.AntiVirus,
                    c => c.AssetTag,
                    c => c.WindowsKey
                    ))
            {
                await _context.SaveChangesAsync();

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

            PopulateDepartmentsDropDownList(_context, Computer.DepartmentID);
            PopulateLocationsDropDownList(_context, Computer.LocationID);
            PopulateTypesDropDownList(_context, Computer.TypeID);
            return(RedirectToPage("./Index"));
        }