コード例 #1
0
 public AdminHardwareVM AddHardware(AdminHardwareVM hw)
 {
     Hardware model = new Hardware()
     {
         HardwareID = hw.HardwareID,
         Category = hw.Category,
         DateDeleted = null,
         HardwareName = hw.HardwareName,
         Notes = hw.Notes,
         Faq = hw.Faq.Select(f => new FAQ()
         {
             Answer = f.Answer,
             FaqID = f.FaqID,
             DateDeleted = null,
             HardwareID = hw.HardwareID,
             Question = f.Question,
             Topic = f.Topic
         }).ToList(),
     };
     using (ApplicationDbContext db = new ApplicationDbContext())
     {
         db.Hardware.Add(model);
         db.SaveChanges();
     }
     return hw;
 }
コード例 #2
0
 public void EditHardware(AdminHardwareVM hardware, int id)
 {
     if (hardware != null)
     {
         Hardware model;
         using (ApplicationDbContext db = new ApplicationDbContext())
         {
             model = db.Hardware.FirstOrDefault(x => x.HardwareID == id);
             model.HardwareName = hardware.HardwareName;
             model.Notes = hardware.Notes;
             model.Category = hardware.Category;
             model.DateDeleted = hardware.DateDeleted;
             db.SaveChanges();
         };
     };
 }
コード例 #3
0
 public AdminHardwareVM NewHardware(AdminHardwareVM hardware)
 {
     if (hardware != null)
     {
         Hardware model = new Hardware()
         {
             HardwareName = hardware.HardwareName,
             Notes = hardware.Notes,
             Category = hardware.Category,
         };
         using (ApplicationDbContext db = new ApplicationDbContext())
         {
             db.Hardware.Add(model);
             db.SaveChanges();
         }
     }
     return hardware;
 }
コード例 #4
0
 public IHttpActionResult Post(AdminHardwareVM editedHardware, int id)
 {
     _adapter.EditHardware(editedHardware, id);
     return Ok();
 }