// user 2's grejor public void AddUser2(AlltBokatWebAPI.Models.ApplicationDbContext context) { var um = new UserManager <ApplicationUser>( new UserStore <ApplicationUser>(context)); var user = new ApplicationUser { Email = "*****@*****.**", UserName = "******", FirstName = "Johan", LastName = "Persson" }; um.Create(user, "!123Damp"); var bookingTimeSlot1 = new BookingTimeSlotModels { startTime = new DateTime(2017, 3, 24, 15, 0, 0), endTime = new DateTime(2017, 3, 24, 16, 0, 0) }; var bookingTimeSlot2 = new BookingTimeSlotModels { startTime = new DateTime(2017, 3, 23, 14, 0, 0), endTime = new DateTime(2017, 3, 23, 15, 0, 0) }; context.BookingTimeSlots.Add(bookingTimeSlot1); context.BookingTimeSlots.Add(bookingTimeSlot2); context.Bookings.Add(new BookingModels { ApplicationUser = user, ApplicationUserId = user.Id, BookingTimeSlotModels = bookingTimeSlot1, BookingTimeSlotModelsId = bookingTimeSlot1.Id, CustomerEmail = "*****@*****.**", CustomerName = "testcustomer1", description = "testcust1's test booking." }); context.Bookings.Add(new BookingModels { ApplicationUser = user, ApplicationUserId = user.Id, BookingTimeSlotModels = bookingTimeSlot2, BookingTimeSlotModelsId = bookingTimeSlot2.Id, CustomerEmail = "*****@*****.**", CustomerName = "testcustomer2", description = "Johans second test booking." }); }
public void AddUser1(AlltBokatWebAPI.Models.ApplicationDbContext context) { var um = new UserManager <ApplicationUser>( new UserStore <ApplicationUser>(context)); var user = new ApplicationUser { Email = "*****@*****.**", UserName = "******", FirstName = "Simon", LastName = "Lindquist" }; um.Create(user, "!123Damp"); var bookingTimeSlot1 = new BookingTimeSlotModels { startTime = new DateTime(2017, 3, 22, 10, 0, 0), endTime = new DateTime(2017, 3, 22, 11, 0, 0) }; var bookingTimeSlot2 = new BookingTimeSlotModels { startTime = new DateTime(2017, 3, 23, 8, 0, 0), endTime = new DateTime(2017, 3, 23, 9, 0, 0) }; context.BookingTimeSlots.Add(bookingTimeSlot1); context.BookingTimeSlots.Add(bookingTimeSlot2); context.Bookings.Add(new BookingModels { ApplicationUser = user, ApplicationUserId = user.Id, BookingTimeSlotModels = bookingTimeSlot1, BookingTimeSlotModelsId = bookingTimeSlot1.Id, CustomerEmail = "*****@*****.**", CustomerName = "testcustomer1", description = "Simons first test booking." }); context.Bookings.Add(new BookingModels { ApplicationUser = user, ApplicationUserId = user.Id, BookingTimeSlotModels = bookingTimeSlot2, BookingTimeSlotModelsId = bookingTimeSlot2.Id, CustomerEmail = "*****@*****.**", CustomerName = "testcustomer2", description = "Simons second test booking." }); }
// user 3's gunk public void AddUser3(AlltBokatWebAPI.Models.ApplicationDbContext context) { var um = new UserManager <ApplicationUser>( new UserStore <ApplicationUser>(context)); var user = new ApplicationUser { Email = "*****@*****.**", UserName = "******", FirstName = "David", LastName = "Nyquist" }; um.Create(user, "!123Damp"); var bookingTimeSlot1 = new BookingTimeSlotModels { startTime = new DateTime(2017, 3, 24, 13, 0, 0), endTime = new DateTime(2017, 3, 24, 14, 0, 0) }; var bookingTimeSlot2 = new BookingTimeSlotModels { startTime = new DateTime(2017, 3, 23, 10, 0, 0), endTime = new DateTime(2017, 3, 23, 11, 0, 0) }; context.BookingTimeSlots.Add(bookingTimeSlot1); context.BookingTimeSlots.Add(bookingTimeSlot2); context.Bookings.Add(new BookingModels { ApplicationUser = user, ApplicationUserId = user.Id, BookingTimeSlotModels = bookingTimeSlot1, BookingTimeSlotModelsId = bookingTimeSlot1.Id, CustomerEmail = "*****@*****.**", CustomerName = "testcustomer1", description = "testcust1's first booking on David." }); context.Bookings.Add(new BookingModels { ApplicationUser = user, ApplicationUserId = user.Id, BookingTimeSlotModels = bookingTimeSlot2, BookingTimeSlotModelsId = bookingTimeSlot2.Id, CustomerEmail = "*****@*****.**", CustomerName = "Testmaster2000", description = "Davids second test booking." }); }
// user 4's grejor public void AddUser4(AlltBokatWebAPI.Models.ApplicationDbContext context) { var um = new UserManager <ApplicationUser>( new UserStore <ApplicationUser>(context)); var user = new ApplicationUser { Email = "*****@*****.**", UserName = "******", FirstName = "Dunder", LastName = "Mannen" }; um.Create(user, "!123Damp"); var bookingTimeSlot1 = new BookingTimeSlotModels { startTime = new DateTime(2017, 3, 28, 11, 0, 0), endTime = new DateTime(2017, 3, 24, 12, 0, 0) }; var bookingTimeSlot2 = new BookingTimeSlotModels { startTime = new DateTime(2017, 3, 26, 12, 0, 0), endTime = new DateTime(2017, 3, 23, 13, 0, 0) }; context.BookingTimeSlots.Add(bookingTimeSlot1); context.BookingTimeSlots.Add(bookingTimeSlot2); context.Bookings.Add(new BookingModels { ApplicationUser = user, ApplicationUserId = user.Id, BookingTimeSlotModels = bookingTimeSlot1, BookingTimeSlotModelsId = bookingTimeSlot1.Id, CustomerEmail = "*****@*****.**", CustomerName = "testcustomer1", description = "unders test booking." }); context.Bookings.Add(new BookingModels { ApplicationUser = user, ApplicationUserId = user.Id, BookingTimeSlotModels = bookingTimeSlot2, BookingTimeSlotModelsId = bookingTimeSlot2.Id, CustomerEmail = "*****@*****.**", CustomerName = "testcustomer2", description = "Dunders egna stund med kund." }); }
public async Task <BookingModels> DeleteBookingModels(int bookingId, string userId) { BookingModels bookingModels = await context.Bookings.FindAsync(bookingId); BookingTimeSlotModels bookingtimeslot = bookingModels.BookingTimeSlotModels; if (bookingModels == null) { return(null); } if (!bookingModels.ApplicationUserId.Equals(userId)) { return(null); } context.Bookings.Remove(bookingModels); context.BookingTimeSlots.Remove(bookingtimeslot); await context.SaveChangesAsync(); return(bookingModels); }