/// <summary> /// Adds a new resource to the database /// </summary> /// <param name="resource">The new resource to be added</param> public void AddResource(Resource resource) { var db = new ReScrumEntities(); var newResource = new DataLayer.Models.Resource { ResourceId = resource.ResourceId, Name = resource.Name, Description = resource.Description, Category = resource.Category, Capacity = resource.Capacity, Location = resource.Location, }; db.Resources.Add(newResource); db.SaveChanges(); }
/// <summary> /// Adds an uncomfirmed booking for to the database /// </summary> /// <param name="db">The database instance</param> /// <param name="slots">The time slots for the booking</param> /// <param name="user">The user</param> /// <param name="resource">The resource</param> /// <param name="date">The date</param> /// <param name="bookedBy">The person who made the group booking</param> public void AddUnconfirmedBooking(ReScrumEntities db, List <DataLayer.Models.Slot> slots, DataLayer.Models.User user, DataLayer.Models.Resource resource, DateTime date, DataLayer.Models.User bookedBy) { foreach (DataLayer.Models.Slot slot in slots) { var booking = new DataLayer.Models.UnconfirmedBooking(); booking.Date = date; booking.Slot = slot; booking.Resource = resource; booking.User = user; booking.BookedBy = bookedBy; db.UnconfirmedBooking.Add(booking); } db.SaveChanges(); }