public static bool Insert(RequestLines requestLines) { if (requestLines == null) { throw new Exception("RequestLine instance must not be null"); } requestLines.Id = 0; context.RequestLines.Add(requestLines); RecalculateRequestTotal(requestLines.RequestId); return(context.SaveChanges() == 1); }
public static bool Delete(RequestLines requestLines) { if (requestLines == null) { throw new Exception("RequestLine instance must not be null"); } var dbrequestline = context.RequestLines.Find(requestLines.Id); if (dbrequestline == null) { throw new Exception("No requestLines with that id."); } context.RequestLines.Remove(dbrequestline); RecalculateRequestTotal(dbrequestline.RequestId); return(context.SaveChanges() == 1); }
public static bool Update(RequestLines requestLines) { if (requestLines == null) { throw new Exception("RequestLine instance must not be null"); } var dbrequestline = context.RequestLines.Find(requestLines.Id); if (dbrequestline == null) { throw new Exception("No requestLines with that id."); } dbrequestline.RequestId = requestLines.RequestId; dbrequestline.ProductId = requestLines.ProductId; dbrequestline.Quantity = requestLines.Quantity; // ... RecalculateRequestTotal(dbrequestline.RequestId); return(context.SaveChanges() == 1); }