public void Delete(int id) { using (var db = new ComputerPartsContext()) { var computerParts = new ComputerParts { Id = id }; db.ComputerParts.Attach(computerParts); db.ComputerParts.Remove(computerParts); db.SaveChanges(); } }
public int Append(ComputerPartDetailDTO computerPart) { int id = -1; using (var db = new ComputerPartsContext()) { ComputerParts computerParts = new ComputerParts { Description = computerPart.Description, Condition = computerPart.Condition, PartType = computerPart.PartType, Location = computerPart.Location, Price = computerPart.Price, Remarks = computerPart.Remarks }; db.ComputerParts.Add(computerParts); db.SaveChanges(); id = computerParts.Id; } return(id); }