public ActionResult ItemBooking(int ItemID, BookingItem usrBooking) { if (ModelState.IsValid) { using (db) { UserAccount listedByUsr = db.UserAccounts.Where(u => u.UserName.Equals(User.Identity.Name.ToString())).FirstOrDefault(); bool obj = db.BookingItems.Any(x => x.ItemID == ItemID && x.BookedBy == listedByUsr.UserID); if (obj == false) { usrBooking.ItemID = ItemID; usrBooking.BookedBy = listedByUsr.UserID; db.BookingItems.Add(usrBooking); } else { BookingItem a = db.BookingItems.Where(x => x.ItemID == ItemID).Where(x => x.BookedBy == listedByUsr.UserID).FirstOrDefault(); db.BookingItems.Remove(a); } db.SaveChanges(); ModelState.Clear(); return(RedirectToAction("ItemDetails", "Item", new { ItemID = ItemID })); } } return(View(usrBooking)); }
public async Task CannotCancelCheckedOutBookingTest() { BookingItem bookingItem = CreateBookingItem(); bookingItem.Status = Constants.CheckedOut; var saga = new ProcessBookingSaga() { Data = new ProcessBookingSaga.BookingData() { BookingNumber = 0, ClientId = "JonSnowClientId", BookingItem = bookingItem } }; var context = new TestableMessageHandlerContext(); CancelBooking cancelBooking = new CancelBooking(); cancelBooking.BookingNumber = 0; cancelBooking.ClientId = "JonSnowClientId"; await saga.Handle(cancelBooking, context) .ConfigureAwait(false); Assert.AreEqual(0, context.PublishedMessages.Length); }
public async Task CheckInTest() { BookingItem bookingItem = CreateBookingItem(); var saga = new ProcessBookingSaga() { Data = new ProcessBookingSaga.BookingData() { BookingNumber = 0, ClientId = "JonSnowClientId", BookingItem = bookingItem } }; var context = new TestableMessageHandlerContext(); CheckIn checkIn = new CheckIn(); checkIn.BookingNumber = 0; checkIn.ClientId = "JonSnowClientId"; await saga.Handle(checkIn, context) .ConfigureAwait(false); var checkedInEvent = (CheckedIn)context.PublishedMessages[0].Message; Assert.AreEqual(0, checkedInEvent.BookingNumber); Assert.AreEqual(Constants.CheckedIn, saga.Data.BookingItem.Status); }
public static List <BookingItem> getBookingItemByID(int bookingID) { List <BookingItem> bookingItemList = new List <BookingItem>(); BookingItem bookingItem; using (SqlConnection conn = new SqlConnection(connectionString)) { SqlCommand cmd = conn.CreateCommand(); conn.Open(); cmd.CommandText = string.Format("select * from BookingItem where BookingID = {0}", bookingID); cmd.CommandTimeout = 0; SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { bookingItem = new BookingItem(reader["BookingItemID"], reader["BookingID"], reader["BookingRecordSystemReferenceCode"], reader["BookingItemIDOriginal"], reader["BookingItemIDPrior"], reader["BookingItemTypeID"], reader["BookingItemStateID"], reader["BookingItemStateIDPending"], reader["BookingFulfillmentMethodID"], reader["BookingFulfillmentStateID"], reader["BookingFulfillmentDate"], reader["UseDateBegin"], reader["UseDateEnd"], reader["BookingRecordSystemID"], reader["AccountingVendorID"], reader["SupplierBookingConfirmationCode"], reader["SupplierBookingConfirmationDate"], reader["BookingItemDesc"], reader["CancelDate"], reader["CancelTUID"], reader["CreateDate"], reader["CreateTUID"], reader["UpdateDate"], reader["UpdateTravelProductID"], reader["UpdateTUID"], reader["RevenueReportingTypeID"], reader["BookDate"], reader["BookTUID"]); bookingItemList.Add(bookingItem); } conn.Close(); } return(bookingItemList); }
public async Task CancelBookingTest() { BookingItem bookingItem = CreateBookingItem(); var saga = new ProcessBookingSaga() { Data = new ProcessBookingSaga.BookingData() { BookingNumber = 0, ClientId = "JonSnowClientId", BookingItem = bookingItem } }; var context = new TestableMessageHandlerContext(); CancelBooking cancelBooking = new CancelBooking(); cancelBooking.BookingNumber = 0; cancelBooking.ClientId = "JonSnowClientId"; await saga.Handle(cancelBooking, context) .ConfigureAwait(false); var bookingCanceled = (BookingCancelled)context.PublishedMessages[0].Message; Assert.AreEqual(0, bookingCanceled.BookingNumber); Assert.AreEqual(Constants.Cancelled, saga.Data.BookingItem.Status); }
public IActionResult PutBookingItem([FromRoute] int id, [FromBody] BookingItem bookingItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bookingItem.Id) { return(BadRequest()); } try { _unitOfWork.BookingItems.Update(bookingItem); } catch (DbUpdateConcurrencyException) { if (!BookingItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Add(BookingDTO booking) { //Save Receiver // var receiver = new Receiver // { // Id = Guid.NewGuid().ToString(), // Name = booking.ReceiverName, // Address = booking.ReceiverAddress, // Phone = booking.ReceiverPhone, // Email = booking.ReceiverEmail, // ZoneId = booking.ZoneId // }; // receiver = await _unitOfWork.Receivers.Add(receiver); var receiver = await _receiverService.Add(booking); //get receiverId var receiverId = receiver.Id; var totalBooking = _context.Bookings.Count(); var courierIdTemp = "0001"; //remove after var bookingSerialNo = Extensions.GenerateSerialForBooking(courierIdTemp, booking.MerchantIdentity, totalBooking + 1); //Place Booking var placeBooking = new Booking { Id = Guid.NewGuid().ToString(), ReceiverId = receiverId, MerchantId = booking.MerchantId, BookingDate = DateTime.Now, TotalAmmount = booking.TotalAmount, Discount = booking.Discount, ItemPrice = booking.ItemPrice, SerialNo = bookingSerialNo, MerchantBill = booking.MerchantBill, CourierBill = booking.CourierBill, ReceiverBill = booking.ReceiverBill, ConditionCharge = booking.ConditionCharge }; placeBooking.Status = "Pending"; var bookingId = placeBooking.Id; await _unitOfWork.Bookings.Add(placeBooking); //Save BookingItems var bookingItem = new BookingItem { BookingId = bookingId, ItemAttributeId = booking.ItemAttributeId, IsInCity = booking.IsInCity, IsOutCity = booking.IsOutCity, IsConditionChargeApply = booking.IsConditionCharge }; await _unitOfWork.BookingItems.Add(bookingItem); var result = await _unitOfWork.CompleteAsync(); if (result == 0) { return(BadRequest("error occured")); } return(Ok()); }
public void OnNavigatedTo(NavigationParameters parameters) { if (parameters.ContainsKey("model")) { RecievedBooking = (BookingItem)parameters["model"]; } }
public void Should_GetBookingItemById(int id) { using (ApplicationDbContext context = SeedContext()) { var entity = new DbRepository <BookingItem>(context); BookingItem getBookingItem = entity.GetById(id); Assert.NotNull(getBookingItem); } }
public ActionResult AboutFor(int ssn) { BookingItem model = new BookingItem(); model.Ssn = ssn.ToString(); model.NextAvailible = DateTime.Now; model.Name = "Ari Freyr Guðmundsson"; return(View(model)); }
public IActionResult PostBookingItem([FromBody] BookingItem bookingItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _unitOfWork.BookingItems.Create(bookingItem); return(CreatedAtAction("GetBookingItem", new { id = bookingItem.Id }, bookingItem)); }
public void OnNavigatedTo(NavigationParameters parameters) { if (parameters.ContainsKey("model")) { RecievedBooking = (BookingItem)parameters["model"]; if (RecievedBooking.times.Length > 0) { PopulatePickers(); } } }
public async Task PlaceBooking(BookingItem bookingItem) { var command = new SubmitBooking { ClientId = Context.ConnectionId, BookingNumber = Interlocked.Increment(ref bookingNumber), BookingItem = bookingItem }; var sendOptions = new SendOptions(); await MvcApplication.EndpointInstance.Send(command, sendOptions); }
private BookingItem CreateBookingItem() { BookingItem bookingItem = new BookingItem(); bookingItem.Name = "Jon snow"; bookingItem.Phone = "13324124"; bookingItem.Email = "*****@*****.**"; bookingItem.CheckInDatetime = DateTime.Now; bookingItem.CheckOutDatetime = DateTime.Now; bookingItem.Status = Constants.Booked; return(bookingItem); }
public void Should_AddBookingItem() { using (ApplicationDbContext context = SeedContext()) { BookingItem BookingItem = new BookingItem { BookingId = 1, AgreedPriceName = "Adult Test", AgreedPrice = 1f, Location = 24 }; var entity = new DbRepository <BookingItem>(context); bool created = entity.Create(BookingItem); Assert.True(created); } }
public void Should_PutBookingItem() { BookingItem testBookingItem = new BookingItem { Id = 1 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.BookingItems.Update(testBookingItem)).Returns(true); BookingItemsController controller = new BookingItemsController(mock.Object); var bookingItems = controller.PutBookingItem(1, testBookingItem); Assert.IsType <NoContentResult>(bookingItems); }
public void Should_GetBookingItem() { BookingItem testBookingItem = new BookingItem { Id = 1, Location = 0, AgreedPriceName = "Adult", AgreedPrice = 5, BookingId = 1 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.BookingItems.GetById(1)).Returns(testBookingItem); BookingItemsController controller = new BookingItemsController(mock.Object); var bookingItem = controller.GetBookingItem(1); Assert.IsType <OkObjectResult>(bookingItem); }
public void ShouldNot_DeleteBookingItem_NotFound() { BookingItem testBookingItem = new BookingItem { Id = 10 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.BookingItems.GetById(10)).Returns((BookingItem)null); BookingItemsController controller = new BookingItemsController(mock.Object); var result = controller.DeleteBookingItem(10); Assert.IsType <NotFoundResult>(result); }
public void Should_PostBookingItem() { BookingItem testBookingItem = new BookingItem { Id = 1, Location = 0, AgreedPriceName = "Adult", AgreedPrice = 5, BookingId = 1 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.BookingItems.Create(testBookingItem)).Returns(true); BookingItemsController controller = new BookingItemsController(mock.Object); var bookingItems = controller.PostBookingItem(testBookingItem); Assert.IsType <CreatedAtActionResult>(bookingItems); }
public async Task PageChangeAsync(BookingItem item) { if (IsBusy) { return; } IsBusy = true; var navigationParams = new NavigationParameters(); navigationParams.Add("model", item); await _navigationService.NavigateAsync("BookingDetailPage", navigationParams, true, true); IsBusy = false; }
public void Should_DeleteBookingItem() { BookingItem testBookingItem = new BookingItem { Id = 1 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.BookingItems.GetById(1)).Returns(testBookingItem); mock.Setup(f => f.BookingItems.Delete(testBookingItem)).Returns(true); BookingItemsController controller = new BookingItemsController(mock.Object); var result = controller.DeleteBookingItem(1); Assert.IsType <OkObjectResult>(result); }
public BookingItem GetNewItem() { var newRoom = new BookingItem { CustomerName = "Default CustomeName", Address = "Default Address", MobileNo = "Default MobileNo", AlternameMobileNo = "Default AlternameMobileNo", IDProof = "Default IDProof", BookFrom = System.DateTime.Now, BookTo = System.DateTime.Now, NoOfMembers = "Default NoOfMembers" }; return(newRoom);//_roomService.GetNewRoom(); }
public void Initiate() { Booking = new Booking(); BookingItems = new List <BookingItem>(); // Get All Type of Room foreach (var item in Enum.GetValues(typeof(RoomType))) { BookingItem _item = new BookingItem { RoomType = (RoomType)item, Qty = 0, BookingId = 0 }; BookingItems.Add(_item); } }
public void ShouldNot_PutBookingItem_ModelStateError() { BookingItem testBookingItem = new BookingItem { Id = 1 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.BookingItems.Update(testBookingItem)).Returns(true); BookingItemsController controller = new BookingItemsController(mock.Object); controller.ModelState.AddModelError("TestError", "Error"); var bookingItems = controller.PutBookingItem(1, testBookingItem); Assert.IsType <BadRequestObjectResult>(bookingItems); }
public void ShouldNot_PostBookingItem_ModelStateError() { BookingItem testBookingItem = new BookingItem { Id = 1, Location = 0, AgreedPriceName = "Adult", AgreedPrice = 5, BookingId = 1 }; Mock <IUnitOfWork> mock = new Mock <IUnitOfWork>(); mock.Setup(f => f.BookingItems.Create(testBookingItem)).Returns(true); mock.Setup(f => f.BookingItems.GetById(1)).Returns(testBookingItem); BookingItemsController controller = new BookingItemsController(mock.Object); controller.ModelState.AddModelError("TestError", "Error"); var bookingItems = controller.PostBookingItem(testBookingItem); Assert.IsType <BadRequestObjectResult>(bookingItems); }
public void Should_BookingItemExist() { using (ApplicationDbContext context = SeedContext()) { var entity = new DbRepository <BookingItem>(context); var bookingItem = new BookingItem { Id = 1 }; if (bookingItem == null) { Assert.True(false); } bool exists = entity.Exists(bookingItem); Assert.True(exists); } }
public void Should_DeleteBookingItem() { using (ApplicationDbContext context = SeedContext()) { var entity = new DbRepository <BookingItem>(context); var bookingItem = new BookingItem { Id = 1 }; if (bookingItem == null) { Assert.True(false); } bool deleted = entity.Delete(bookingItem); Assert.True(deleted); } }
public BookingItem InsertItem([FromBody] BookingItem model) { var allRooms = _context.Rooms; // если id > нуля , то мы находим запись, которуб нужно редактировать. и редактируем ее if (model.Id > 0) { var item = _context.Bookings.FirstOrDefault(x => x.Id == model.Id); if (item != null) { item.CustomerName = model.CustomerName; item.Address = model.Address; item.MobileNo = model.MobileNo; item.AlternameMobileNo = model.AlternameMobileNo; item.IDProof = model.IDProof; item.BookFrom = model.BookFrom; item.BookTo = model.BookTo; item.NoOfMembers = model.NoOfMembers; _context.Bookings.Update(item); } } else { if (allRooms.Count() < 50) { _context.Bookings.Add(model); } else { return(null); } } _context.SaveChanges(); var ddd = _context.Bookings.ToList(); return(new BookingItem { CustomerName = "test" }); }
public async void Should_GetShowingAllocations() { // add seed data for showing & foreign dependencies var client = _factory.CreateClient(); // spoof admin access IJwtManager jwtManager = new InMemoryJwtManager(_configuration); string testToken = await jwtManager.GenerateJwtStringAsync("*****@*****.**", new List <Claim> { new Claim(ClaimTypes.Role, "admin") }); client.DefaultRequestHeaders.Add("Authorization", "Bearer " + testToken); // get antiforgery token, and add to header var aftResponse = await client.GetAsync("/api/account/getCSRFToken"); var tokenData = JsonConvert.DeserializeAnonymousType(aftResponse.Content.ReadAsStringAsync().Result, new { Token = "", TokenName = "" }); client.DefaultRequestHeaders.Add(tokenData.TokenName, tokenData.Token); Event @event = new Event { Name = "Test Event", Description = "Event Desc", Image = "", Duration = 120, AgeRating = AgeRatingType.BBFC_PG }; string json = JsonConvert.SerializeObject(@event); var content = new StringContent(json, Encoding.UTF8, "application/json"); var postResponse = await client.PostAsync("api/events", content); Venue venue = new Venue { Name = "Test Venue", Description = "Venue Desc", Address1 = "Addr1", Address2 = "Addr2", Address3 = "Addr3", Address4 = "Addr4", Address5 = "Addr5", ContactPhone = "", Image = "", Website = "", Instagram = "", Facebook = "", Twitter = "", Facilities = FacilityFlags.Bar | FacilityFlags.GuideDogsPermitted, LatLong = "" }; json = JsonConvert.SerializeObject(venue); content = new StringContent(json, Encoding.UTF8, "application/json"); postResponse = await client.PostAsync("api/venues", content); Room room = new Room { Name = "Test Room", Description = "Room Desc", Columns = 10, Rows = 10, Isles = "", VenueId = 1 }; json = JsonConvert.SerializeObject(room); content = new StringContent(json, Encoding.UTF8, "application/json"); postResponse = await client.PostAsync("api/rooms", content); PricingStrategy strategy = new PricingStrategy { Name = "Test Strategy", Description = "Strategy Desc" }; json = JsonConvert.SerializeObject(strategy); content = new StringContent(json, Encoding.UTF8, "application/json"); postResponse = await client.PostAsync("api/pricingstrategies", content); Showing showing = new Showing { Id = 0, StartTime = DateTime.Now, EndTime = DateTime.Now.AddMinutes(120), PricingStrategyId = 1, EventId = 1, RoomId = 1 }; json = JsonConvert.SerializeObject(showing); content = new StringContent(json, Encoding.UTF8, "application/json"); postResponse = await client.PostAsync("api/showings", content); Customer customer = new Customer { Address1 = "", Address2 = "", Address3 = "", Address4 = "", Address5 = "", ContactEmail = "", ContactPhone = "", FirstName = "", LastName = "" }; json = JsonConvert.SerializeObject(customer); content = new StringContent(json, Encoding.UTF8, "application/json"); postResponse = await client.PostAsync("api/customers", content); Booking booking = new Booking { Id = 0, BookedDate = DateTime.Now, ShowingId = 1, CustomerId = 1, Status = BookingStatus.PaymentComplete }; json = JsonConvert.SerializeObject(booking); content = new StringContent(json, Encoding.UTF8, "application/json"); postResponse = await client.PostAsync("api/bookings", content); for (int i = 0; i < 5; i++) { BookingItem bookingItem = new BookingItem { Id = 0, AgreedPrice = 4.2f, AgreedPriceName = "", BookingId = 1, Location = i }; json = JsonConvert.SerializeObject(bookingItem); content = new StringContent(json, Encoding.UTF8, "application/json"); postResponse = await client.PostAsync("api/bookingitems", content); } var availabilityResponse = await client.GetAsync("api/showings/allocations/1"); if (availabilityResponse.StatusCode != System.Net.HttpStatusCode.OK) { Assert.True(false); } string data = await availabilityResponse.Content.ReadAsStringAsync(); if (string.IsNullOrEmpty(data)) { Assert.True(false); } }
public async Task Add(BookingItem bookingItem) { await _context.BookingItems.AddAsync(bookingItem); }