public Core.Models.CPU LoadById(int Id) { Core.Models.CPU cpu = null; using (var db = new DBContext()) { cpu = db.CPUs.FirstOrDefault(x => x.Id == Id); } return(cpu); }
public bool InsertCPU(Core.Models.CPU CPU) { try { using (var db = new DBContext()) { db.CPUs.Add(CPU); db.SaveChanges(); ActivityLogFunction.WriteActivity("Insert cpu"); } return(true); } catch (Exception e) { } return(false); }
public bool UpdateCPU(Core.Models.CPU CPU) { if (CPU == null) { return(false); } try { using (var db = new DBContext()) { int id = CPU.Id; var temp = db.CPUs.FirstOrDefault(x => x.Id == id); PropertyCopier <Core.Models.CPU, Core.Models.CPU> .Copy(CPU, temp); db.SaveChanges(); ActivityLogFunction.WriteActivity("Update case"); return(true); } } catch (Exception e) { } return(false); }