public static UserPayment LoadById(Guid id) { try { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { tblUserPayment UserPaymentRow = dc.tblUserPayments.FirstOrDefault(a => a.Id == id); if (UserPaymentRow != null) { return(new UserPayment { Id = UserPaymentRow.Id, UserId = UserPaymentRow.UserId, CardHolderName = UserPaymentRow.CardHolderName, CardNumber = UserPaymentRow.CardNumber, ExpirationDate = UserPaymentRow.ExpirationDate, CVC = UserPaymentRow.CVC }); } else { throw new Exception("Row not found..."); } } } catch (Exception ex) { throw ex; } }
public static int Delete(Guid id) { try { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { tblUserPayment deletedrow = dc.tblUserPayments.FirstOrDefault(a => a.Id == id); if (deletedrow != null) { dc.tblUserPayments.Remove(deletedrow); return(dc.SaveChanges()); } else { return(0); } } } catch (Exception ex) { throw ex; } }
public static int Update(UserPayment userPayment) { try { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { tblUserPayment updatedrow = dc.tblUserPayments.FirstOrDefault(a => a.Id == userPayment.Id); if (updatedrow != null) { updatedrow.UserId = userPayment.UserId; updatedrow.CardHolderName = userPayment.CardHolderName; updatedrow.CardNumber = userPayment.CardNumber; updatedrow.ExpirationDate = userPayment.ExpirationDate; updatedrow.CVC = userPayment.CVC; return(dc.SaveChanges()); } else { return(0); } } } catch (Exception ex) { throw ex; } }
public static int Update(Guid id, Guid userid, string cardholdername, string cardnumber, string expirationdate, string cvc) { try { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { tblUserPayment updatedrow = dc.tblUserPayments.FirstOrDefault(a => a.Id == id); if (updatedrow != null) { updatedrow.UserId = userid; updatedrow.CardHolderName = cardholdername; updatedrow.CardNumber = cardnumber; updatedrow.ExpirationDate = expirationdate; updatedrow.CVC = cvc; return(dc.SaveChanges()); } else { return(0); } } } catch (Exception ex) { throw ex; } }
public static bool Insert(Guid userid, string cardholdername, string cardnumber, string expirationdate, string cvc) { try { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { // Make a new row tblUserPayment newrow = new tblUserPayment(); // Set the properties newrow.Id = Guid.NewGuid(); newrow.UserId = userid; newrow.CardHolderName = cardholdername; newrow.CardNumber = cardnumber; newrow.ExpirationDate = expirationdate; newrow.CVC = cvc; // Do the Insert dc.tblUserPayments.Add(newrow); // Commit the insert return(Convert.ToBoolean(dc.SaveChanges())); } } catch (Exception ex) { throw ex; } }
public static bool Insert(UserPayment userPayment) { try { using (FoodOrderSystemEntities dc = new FoodOrderSystemEntities()) { // Make a new row tblUserPayment newrow = new tblUserPayment(); // Set the properties newrow.Id = Guid.NewGuid(); newrow.UserId = userPayment.UserId; newrow.CardHolderName = userPayment.CardHolderName; newrow.CardNumber = userPayment.CardNumber; newrow.ExpirationDate = userPayment.ExpirationDate; newrow.CVC = userPayment.CVC; // Do the Insert dc.tblUserPayments.Add(newrow); // Commit the insert return(Convert.ToBoolean(dc.SaveChanges())); } } catch (Exception ex) { //throw ex; return(false); } }