public static bool Insert(RequestLines rline) { if (rline == null) { throw new Exception("Request Line instant must not be null"); } rline.Id = 0; context.RequestLines.Add(rline); //ReCalRequestTotal(rline.RequestId); return(context.SaveChanges() == 1); }
public static bool Delete(RequestLines rline) { if (rline == null) { throw new Exception("RequestLine instant must not be null"); } var dbrline = context.RequestLines.Find(rline.Id); if (dbrline == null) { throw new Exception("No requestline with that ID"); } context.RequestLines.Remove(dbrline); //ReCalRequestTotal(dbrline.RequestId); return(context.SaveChanges() == 1); }
public static bool Update(RequestLines rline) { if (rline == null) { throw new Exception("Request Line instant must not be null"); } var dbrline = context.RequestLines.Find(rline.Id); if (dbrline == null) { throw new Exception("No requestline with that ID"); } dbrline.Id = rline.Id; dbrline.RequestId = rline.RequestId; dbrline.ProductId = rline.ProductId; dbrline.Quantity = rline.Quantity; //ReCalRequestTotal(dbrline.RequestId); return(context.SaveChanges() == 1); }