public async Task <IActionResult> ArchiveConfirm(int id)
        {
            var phyEquipment = await _context.PhyEquipments.SingleOrDefaultAsync(m => m.PhyEquipmentID == id);

            PhyArchive phyArchive = new PhyArchive();

            if (phyArchive != null)
            {
                phyArchive.OrderID        = phyEquipment.OrderID;
                phyArchive.Type           = phyEquipment.Type;
                phyArchive.SerialNumber   = phyEquipment.SerialNumber;
                phyArchive.InstalledDate  = phyEquipment.InstalledDate;
                phyArchive.ArchiveDate    = DateTime.Today;
                phyArchive.EquipmentName  = phyEquipment.EquipmentName;
                phyArchive.EquipmentModel = phyEquipment.EquipmentModel;
                phyArchive.Comments       = phyEquipment.Comments;
                _context.PhyArchives.Add(phyArchive);
                await _context.SaveChangesAsync();
            }
            _context.PhyEquipments.Remove(phyEquipment);
            sp_Logging("3-Remove", "Delete", "User deleted a Physics Equipment where ID=" + id.ToString(), "Success");
            await _context.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Edit(int id, [Bind("PhyArchiveID,SerialNumber,InstalledDate,ArchiveDate,EquipmentModel,EquipmentName,OrderID,Type,Comments")] PhyArchive phyArchive)
        {
            if (id != phyArchive.PhyArchiveID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(phyArchive);
                    sp_Logging("2-Change", "Edit", "User edited a Physics Archive where ID= " + id.ToString(), "Success");
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PhyArchiveExists(phyArchive.PhyArchiveID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Index"));
            }
            ViewData["OrderID"] = new SelectList(_context.Orders, "OrderID", "OrderID", phyArchive.OrderID);
            return(View(phyArchive));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("PhyArchiveID,SerialNumber,InstalledDate,ArchiveDate,EquipmentModel,EquipmentName,OrderID,Type,Comments")] PhyArchive phyArchive)
        {
            if (ModelState.IsValid)
            {
                _context.Add(phyArchive);
                await _context.SaveChangesAsync();

                sp_Logging("2-Change", "Create", "User created a physics archive", "Success");
                return(RedirectToAction("Index"));
            }
            ViewData["OrderID"] = new SelectList(_context.Orders, "OrderID", "OrderID", phyArchive.OrderID);
            return(View(phyArchive));
        }