private void MakeGroup(FacilityDownTimeRepository repo, InsertReservationArgs args) { if (args.Tools.Count() > 0) { ValidateDateRange(args); var reservations = repo.GetReservationsByDateRange(args.Start, args.End, false); // 2009-07-19 make a reservation group int groupId = repo.CreateNewFacilityDownTime(args.ClientID, args.Start, args.End); // If we ever want to allow notes for FDT reservations, do it here. string notes = args.Notes; // Loop through each selected tool and make reservation and delete other people's reservation foreach (int resourceId in args.Tools) { // Find and Remove any un-started reservations made during time of repair var existing = reservations.Where(x => x.ResourceID == resourceId).ToList(); HandleExistingReservations(repo, existing, args.ClientID, args.End); repo.InsertFacilityDownTimeReservation(resourceId, args.ClientID, groupId, args.Start, args.End, notes); } } else { throw new Exception("No tools selected, so no reservations were made."); } }
private void ModifyGroup(FacilityDownTimeRepository repo, UpdateReservationArgs args) { ValidateDateRange(args); repo.UpdateFacilityDownTime(args.GroupID, args.Start, args.End); repo.UpdateReservationsByGroup(args.GroupID, args.Start, args.End, args.Notes); var group = repo.GetReservationsByGroup(args.GroupID); var reservations = repo.GetReservationsByDateRange(args.Start, args.End, false); //Delete all the reservations in this period foreach (var rsv in group) { // Find and Remove any unstarted reservations made during time of repair var existing = reservations.Where(x => x.ResourceID == rsv.ResourceID).ToList(); HandleExistingReservations(repo, existing, args.ClientID, args.End); } }