public void DeleteRentalById(long id) { Rentals rentalToDelete = db.Rentals.SingleOrDefault(r => r.rentalID == id); if (rentalToDelete != null) { db.Rentals.Remove(rentalToDelete); } }
public Rentals GetLastRentalByToolId(long toolId) { Rentals rental = db.Rentals.Include("Customers") .Include("Customers1") .Include("PayTypes") .Include("Tools") .Where(r => r.toolID == toolId).OrderByDescending(re => re.rentalID).FirstOrDefault(); return(rental); }
public void UpdateRental(Rentals rental) { db.Rentals.Attach(rental); db.Entry(rental).State = EntityState.Modified; db.Entry(rental.Tools).State = EntityState.Modified; //Rentals rentalToUpdate = db.Rentals.SingleOrDefault(r => r.rentalID == rental.rentalID); //rentalToUpdate.actualPrice = rental.actualPrice; //rentalToUpdate.contactID = rental.contactID; //rentalToUpdate.customerID = rental.customerID; //rentalToUpdate.discount = rental.discount; //rentalToUpdate.groupID = rental.groupID; //rentalToUpdate.isClean = rental.isClean; //rentalToUpdate.isPaid = rental.isPaid; //rentalToUpdate.payTypeID = rental.payTypeID; //rentalToUpdate.rentalEnd = rental.rentalEnd; //rentalToUpdate.rentalRealEnd = rental.rentalRealEnd; //rentalToUpdate.rentalStart = rental.rentalStart; //rentalToUpdate.toolID = rental.toolID; db.SaveChanges(); }
public void AddRental(Rentals rental) { db.Rentals.Add(rental); db.SaveChanges(); }
public void UpdateRental(Rentals rental) { throw new NotImplementedException(); }
public void AddRental(Rentals rental) { throw new NotImplementedException(); }
public static void Send(Rentals r) { Messenger.Default.Send(r, MessageTypes.newRentAdded); }
public static Rentals convertRental(RentalRepresentation rental) { Rentals convertedRental = new Rentals() { actualPrice = rental.actualPrice, customerID = rental.customer.id, discount = (float)rental.discount * 100, isClean = rental.isClean, rentalID = rental.id, rentalEnd = rental.rentalEnd, isPaid = rental.isPaid, payTypeID = rental.payType.id, rentalRealEnd = rental.rentalRealEnd, rentalStart = rental.rentalStart, toolID = rental.tool.id }; if (rental.group != null && rental.group.id != default(long)) { convertedRental.groupID = rental.group.id; } convertedRental.Tools = convertTool(rental.tool); if (rental.customer.isFirm && rental.contact != null) { convertedRental.contactID = rental.contact.id; convertedRental.Customers1 = convertCustomer(rental.contact); } return convertedRental; }
public static RentalRepresentation convertRental(Rentals rental) { RentalRepresentation convertedRental = new RentalRepresentation() { actualPrice = rental.actualPrice, contact = convertCustomer(rental.Customers1), customer = convertCustomer(rental.Customers), discount = rental.discount / 100, //group = DataProxy.Instance.GetRentalGroupById(rental.groupID), - Couses infinite cycle isClean = rental.isClean, id = rental.rentalID, isPaid = rental.isPaid, payType = convertPayType(rental.PayTypes), rentalEnd = rental.rentalEnd, rentalRealEnd = rental.rentalRealEnd, rentalStart = rental.rentalStart, tool = convertTool(rental.Tools) }; //int selfIndex = convertedRental.group.rentals.IndexOf(convertedRental.group.rentals.SingleOrDefault(r => r.id == convertedRental.id)); //convertedRental.group.rentals[selfIndex] = convertedRental; return convertedRental; }