public void UpdateRentalGroup(RentalGroups rentalGroup) { RentalGroups rentalGroupToUpdate = db.RentalGroups.SingleOrDefault(rg => rg.groupID == rentalGroup.groupID); rentalGroupToUpdate.comment = rentalGroup.comment; rentalGroupToUpdate.deposit = rentalGroup.deposit; rentalGroupToUpdate.isOpen = rentalGroup.isOpen; db.SaveChanges(); }
public long AddRentalGroup(RentalGroups rentalGroup) { db.RentalGroups.Add(rentalGroup); foreach (var rental in rentalGroup.Rentals) { db.Entry(rental.Tools).State = EntityState.Modified; db.Entry(rental.Customers).State = EntityState.Modified; if (rental.Customers1 != null) { db.Entry(rental.Customers1).State = EntityState.Modified; } } db.SaveChanges(); return(rentalGroup.groupID); }
public long AddRentalGroup(RentalGroups rentalGroup) { db.RentalGroups.Add(rentalGroup); foreach (var rental in rentalGroup.Rentals) { db.Entry(rental.Tools).State = EntityState.Modified; db.Entry(rental.Customers).State = EntityState.Modified; if (rental.Customers1 != null) { db.Entry(rental.Customers1).State = EntityState.Modified; } } db.SaveChanges(); return rentalGroup.groupID; }
public void UpdateRentalGroup(RentalGroups rentalGroup) { throw new NotImplementedException(); }
public long AddRentalGroup(RentalGroups rentalGroup) { throw new NotImplementedException(); }
public static RentalGroups convertRentalGroup(RentalGroup_Representation rentalGroup) { RentalGroups convertedRentalGroup = new RentalGroups() { groupID = rentalGroup.id, comment = rentalGroup.comment, deposit = rentalGroup.deposit, isOpen = rentalGroup.isOpen }; Customers customer = convertCustomer(rentalGroup.rentals.FirstOrDefault().customer); Customers contact = null; if (rentalGroup.rentals.FirstOrDefault().contact != null) { contact = convertCustomer(rentalGroup.rentals.FirstOrDefault().contact); } foreach (var rental in rentalGroup.rentals) { var convertedRental = convertRental(rental); convertedRental.Customers = customer; if (contact != null) { convertedRental.Customers1 = contact; } convertedRentalGroup.Rentals.Add(convertedRental); } return convertedRentalGroup; }
public static RentalGroup_Representation convertRentalGroup(RentalGroups rentalGroup) { RentalGroup_Representation convertedRentalGroup = new RentalGroup_Representation() { comment = rentalGroup.comment, deposit = rentalGroup.deposit ?? 0, id = rentalGroup.groupID, isOpen = rentalGroup.isOpen }; foreach (Rentals rental in rentalGroup.Rentals) { RentalRepresentation rentalToAdd = convertRental(rental); rentalToAdd.group = convertedRentalGroup; convertedRentalGroup.rentals.Add(rentalToAdd); } return convertedRentalGroup; }