public void MakeBooking_CheckSavingPromoCode()
        {
            BookingEntity saveOutput = null;

            var repo = new Mock <IRepository <BookingEntity> >();

            repo.Setup(x => x.GetAll()).Returns((new List <BookingEntity>()).AsQueryable());
            repo.Setup(x => x.Save(It.IsAny <BookingEntity>())).Callback <BookingEntity>(x => saveOutput = x);

            var costEvaluationServiceMock = new Mock <ICostEvaluationService>();

            costEvaluationServiceMock.Setup(x =>
                                            x.EvaluateBookingCost(It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <string>()))
            .Returns(new BookingCostDto {
                TotalCost = 100, PromoCode = new PromoCodeInfoDto {
                    Id = 100500
                }
            });

            var bookingService = new BookingService(repo.Object, null, costEvaluationServiceMock.Object, null, _dateService);

            var bookingInfo = new MakeBookingInfoDto
            {
                Date = DateTime.UtcNow.Date,
                From = 13,
                To   = 15
            };

            bookingService.MakeBooking(bookingInfo, new CurrentUser {
                Phone = "1"
            });

            Assert.AreEqual(100500, saveOutput.PromoCodeId);
        }
        public void MakeBooking_CheckSaving()
        {
            BookingEntity saveOutput = null;

            var repo = new Mock <IRepository <BookingEntity> >();

            repo.Setup(x => x.GetAll()).Returns((new List <BookingEntity>()).AsQueryable());
            repo.Setup(x => x.Save(It.IsAny <BookingEntity>())).Callback <BookingEntity>(x => saveOutput = x);

            var bookingService = new BookingService(repo.Object, null, _costEvaluationService, null, _dateService);

            var bookingInfo = new MakeBookingInfoDto
            {
                Date = DateTime.UtcNow.Date,
                From = 13,
                To   = 15
            };

            bookingService.MakeBooking(bookingInfo, new CurrentUser {
                Phone = "1", UserId = "SomeUser"
            });

            Assert.AreEqual(DateTime.UtcNow.Date.AddHours(13), saveOutput.From);
            Assert.AreEqual(DateTime.UtcNow.Date.AddHours(16), saveOutput.To);
            Assert.AreEqual(BookingStatusEnum.Unpaid, saveOutput.Status);
            Assert.IsNotNull(saveOutput.Guid);
            Assert.AreEqual(100, saveOutput.Cost);
            Assert.AreEqual("SomeUser", saveOutput.UserId);
            Assert.AreEqual(null, saveOutput.PromoCodeId);
        }
        public BookingResponse BookMovie(BookingEntity bookingEntity)
        {
            int hallCapacity = HallCapacity(bookingEntity.MovieScheduleId);

            int bookedSeats = BookedSeats(bookingEntity.MovieScheduleId);

            BookingResponse bookingReponse;

            if (bookingEntity.NumberOfSeat + bookedSeats > hallCapacity)
            {
                bookingReponse = Converter.BookingEntityToResponse(false, 0, 0);
            }
            else
            {
                int totalTicketPrice = TotalTicketPrice(bookingEntity.MovieScheduleId, bookingEntity.NumberOfSeat);

                bookingReponse = Converter.BookingEntityToResponse(true, bookingEntity.NumberOfSeat, totalTicketPrice);

                db.Bookings.Add(bookingEntity);

                try
                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException)
                {
                    return(null);
                }
            }

            return(bookingReponse);
        }
Ejemplo n.º 4
0
        public async Task <BookingEntity> Update(BookingEntity entity)
        {
            var updateEntity = _coworkingDbContext.Bookings.Update(entity);
            await _coworkingDbContext.SaveChangesAsync();

            return(updateEntity.Entity);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Configurar as datas de checkin e checkout
        /// </summary>
        /// <param name="bookingEntity"></param>
        private void ConfigDate(BookingEntity bookingEntity)
        {
            var referenceDate = DateTime.Now.Date.Add(new TimeSpan(14, 00, 0));

            bookingEntity.CheckIn  = referenceDate;
            bookingEntity.CheckOut = referenceDate.AddDays(bookingEntity.Days);
        }
Ejemplo n.º 6
0
 public ActionResult Booking(BookingEntity booking)
 {
     if (!booking.IsSlotCheckWasMade)
     {
         var events = Api.GetEventsFromCalendar(booking.PickUpDateTime, booking.PickUpDateTime.Add(booking.TransferTime));
         if (events.Items != null && events.Items.Count > 0)
         {
             booking.IsSlotAvailable = false;
         }
         else
         {
             booking.IsSlotAvailable = true;
         }
         booking.IsSlotCheckWasMade = true;
     }
     if (Request.HttpMethod == "POST")
     {
         using (var db = new DefaultContext())
         {
             booking.ConfirmationCode = Guid.NewGuid();
             //TODO: fix this
             booking.DriverActualDepartureTime = booking.PickUpDateTime;
             booking.PickUpTime = booking.PickUpDateTime;
             db.BookingEntities.Add(booking);
             db.SaveChanges();
         }
         Api.SendEmailViaGmail(booking, false);
     }
     return(View(booking));
 }
Ejemplo n.º 7
0
        public PenaltyDto ReturnBook(string Username, string BookName, DateTime returnDate)
        {
            BookingDto    NewBookingDto = this.GetBooking(Username, BookName);
            BookingEntity bookingEntity = new BookingEntity();

            bookingEntity.BookId             = NewBookingDto.BookId;
            bookingEntity.EndBookingDate     = NewBookingDto.EndBookingDate;
            bookingEntity.LibraryAppUsername = NewBookingDto.LibraryAppUsername;
            bookingEntity.StartBookingDate   = NewBookingDto.StartBookingDate;
            _dblibrary.ReturnBook(bookingEntity);

            if (NewBookingDto.EndBookingDate < returnDate)
            {
                PenaltyEntity penalty = new PenaltyEntity();
                penalty.BookingId          = bookingEntity.Id;
                penalty.BookId             = bookingEntity.BookId;
                penalty.LibraryAppUsername = bookingEntity.LibraryAppUsername;
                _dblibrary.CreatePenalty(penalty);

                PenaltyDto penaltyDto = new PenaltyDto();
                penaltyDto.Id                 = penalty.Id;
                penaltyDto.BookId             = penalty.BookId;
                penaltyDto.BookingId          = penalty.BookingId;
                penaltyDto.LibraryAppUsername = penalty.LibraryAppUsername;
                return(penaltyDto);
            }
            else
            {
                _dblibrary.ReturnBook(bookingEntity);
                return(null);
            }
        }
        public async Task UpdateBookingShouldUpdateFieldsAsync()
        {
            // arrange
            var booking = new BookingEntity {
                Id = Guid.NewGuid(), UserEntityId = _currentUserEntity.Id
            };

            _bookingList.Add(booking);

            var model = new UpdateBookingModel
            {
                BookingStatusCode   = "testBookingUpdate",
                SelfBooked          = true,
                DateOfBooking       = DateTime.UtcNow.ToLocalTime(),
                OtherBookingDetails = "testOtherBookingDetails"
            };

            // act
            var result = await _bookingsQueryProcessor.Update(booking.Id, model);

            // assert
            result.Should().Be(booking);
            result.BookingStatusCode.Should().Be(model.BookingStatusCode);
            result.SelfBooked.Should().Be(model.SelfBooked);
            result.UserEntityId.Should().Be(_currentUserEntity.Id);

            _unitOfWorkMock.Verify(x => x.CommitAsync());
        }
Ejemplo n.º 9
0
        public static List <IBooking> GetBooking(SearchCriteria searchCriteria, int ID, string CalledFrom)
        {
            string          strExecution = "[exp].[prcGetBookingList]";
            List <IBooking> lstBooking   = new List <IBooking>();

            using (DbQuery oDq = new DbQuery(strExecution))
            {
                oDq.AddIntegerParam("@BookingID", ID);
                oDq.AddVarcharParam("@CalledFrom", 1, CalledFrom);
                oDq.AddVarcharParam("@SchBookingNo", 100, searchCriteria.BookingNo);
                oDq.AddVarcharParam("@SchBookingRefNo", 100, searchCriteria.StringOption1);
                oDq.AddVarcharParam("@SchBookingParty", 100, searchCriteria.StringOption2);
                oDq.AddVarcharParam("@SchVesselName", 100, searchCriteria.Vessel);
                oDq.AddVarcharParam("@SchVoyageNo", 100, searchCriteria.Voyage);
                oDq.AddVarcharParam("@SchLocation", 100, searchCriteria.Location);
                oDq.AddVarcharParam("@SchLineName", 100, searchCriteria.LineName);
                oDq.AddIntegerParam("@Status", searchCriteria.IntegerOption1);
                oDq.AddVarcharParam("@SortExpression", 50, searchCriteria.SortExpression);
                oDq.AddVarcharParam("@SortDirection", 4, searchCriteria.SortDirection);
                DataTableReader reader = oDq.GetTableReader();

                while (reader.Read())
                {
                    IBooking oIH = new BookingEntity(reader);
                    lstBooking.Add(oIH);
                }
                reader.Close();
            }
            return(lstBooking);
        }
Ejemplo n.º 10
0
        private void SaveBookingHeaderDetails(long BookingId)
        {
            IBooking objBooking = new BookingEntity();

            if (Convert.ToInt32(ViewState["FRIEGHTPAYABLEATID"]) == 0)
            {
                lblMessage.Text = ResourceManager.GetStringWithoutName("ERR00085");
                return;
            }
            objBooking.BookingID           = BookingId;
            objBooking.FreightPayableId    = Convert.ToInt32(ViewState["FRIEGHTPAYABLEATID"]);
            objBooking.BrokeragePayable    = Convert.ToBoolean(rdblBorkerage.SelectedValue);
            objBooking.BrokeragePercentage = Convert.ToDecimal(txtBrokeragePercent.Text);
            objBooking.BrokeragePayableId  = Convert.ToInt32(ViewState["BROKERAGEPAYABLEID"]);
            objBooking.RefundPayable       = Convert.ToBoolean(rdblRefundPayable.SelectedValue);
            objBooking.RefundPayableId     = Convert.ToInt32(ViewState["REFUNDPAYABLEID"]);
            objBooking.ExportRemarks       = txtRemarks.Text.Trim();
            objBooking.RateReference       = txtRateReference.Text.Trim();
            objBooking.RateType            = ddlRateType.SelectedValue;
            objBooking.UploadPath          = hdnFilePath.Value;
            objBooking.SlotOperatorId      = Convert.ToInt32(ddlSlot.SelectedValue);
            objBooking.Shipper             = txtShipper.Text.Trim();
            objBooking.ModifiedBy          = _userId;
            objBooking.PpCc       = ddlPpCc.SelectedValue;
            objBooking.ModifiedOn = DateTime.Now;

            BookingBLL.UpdateBooking(objBooking);
        }
Ejemplo n.º 11
0
        public void AddUpdateBooking(BookingEntity bookingRequest)
        {
            bookingRequest.BookingId = Guid.NewGuid().ToString();
            var bookingEntity = new booking()
            {
                BookedBy       = bookingRequest.BookedBy,
                bookedtables   = new List <bookedtable>(),
                BookingDate    = bookingRequest.BookingDate,
                BookingId      = bookingRequest.BookingId.ToString(),
                Email          = bookingRequest.Email,
                EndTime        = bookingRequest.EndTime,
                FirstName      = bookingRequest.FirstName,
                LastName       = bookingRequest.LastName,
                Notes          = bookingRequest.Notes,
                NumberOfGuests = bookingRequest.NumberOfGuests,
                PhoneNumber    = bookingRequest.PhoneNumber,
                StartTime      = bookingRequest.StartTime,
                HasArrived     = bookingRequest.hasArrived,
                CustomerId     = _customerId
            };
            var customerTableList = _dataAccess.GetTableList();

            foreach (var table in bookingRequest.TableNumbers)
            {
                var selectedTable = customerTableList.FirstOrDefault(t => t.TableNumber == table.TableNumber);
                bookingEntity.bookedtables.Add(new bookedtable()
                {
                    BookingId = bookingRequest.BookingId.ToString(),
                    TableId   = selectedTable.TableId
                });
            }

            _dataAccess.AddUpdateBooking(bookingEntity);
        }
Ejemplo n.º 12
0
        public void PrepareBookingPaymnent()
        {
            var bookingEntity = new BookingEntity
            {
                Guid = Guid.NewGuid(),
                Cost = 500
            };
            var settings = new Mock <IOptions <PayServiceSettings> >();

            settings.Setup(x => x.Value).Returns(new PayServiceSettings
            {
                YandexId = "yandexid"
            });
            var service = new PayService(null, null, null, settings.Object, new DateService());

            var result = service.PrepareBookingPaymnent(bookingEntity);

            Assert.AreEqual(8, result.Form.Count());
            Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Url));
            Assert.AreEqual("yandexid", result.Form.First(x => x.Name == "receiver").Value);
            Assert.AreEqual(bookingEntity.Guid.ToString(), result.Form.First(x => x.Name == "label").Value);
            Assert.AreEqual(bookingEntity.Cost.ToString(CultureInfo.InvariantCulture), result.Form.First(x => x.Name == "sum").Value);
            Assert.AreEqual("small", result.Form.First(x => x.Name == "quickpay-form").Value);
            Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Form.First(x => x.Name == "short-dest").Value));
            Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Form.First(x => x.Name == "paymentType").Value));
            Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Form.First(x => x.Name == "formcomment").Value));
            Assert.IsTrue(!string.IsNullOrWhiteSpace(result.Form.First(x => x.Name == "targets").Value));
        }
Ejemplo n.º 13
0
        public BookingViewModel(LinkedList <INavigableViewModel> navigation, Booking booking, LinkedListNode <INavigableViewModel> prevNode = null)
        {
            _pcs                         = new PropertyChangeSupport(this);
            _navigation                  = navigation;
            _parameters                  = new BookingParametersViewModel(booking);
            _parameters.Defined         += _parameters_defined;
            _parameters.PropertyChanged += _parametersChanged;
            _parametersValidated         = false;
            _booking                     = booking;
            _clientEntity                = new ClientEntity(_booking.Client);
            _bookingEntity               = new BookingEntity(_booking);
            _clientEntity.Bookings.Add(_bookingEntity);
            _computeTitle(_clientEntity);
            _clientEntity.PropertyChanged += _clientChanged;

            _searchClientCommand    = new DelegateCommandAsync <BookingViewModel>(_searchClient, false);
            _newClientCommand       = new DelegateCommandAsync <BookingViewModel>(_newClient, false);
            _validateBookingCommand = new DelegateCommandAsync <BookingViewModel>(_validateBooking, false);

            if (prevNode == null)
            {
                _navigation.AddLast(this);
            }
            else
            {
                _navigation.AddAfter(prevNode, this);
            }
        }
Ejemplo n.º 14
0
 public virtual bool ParkingPlaceAvailabe(FloorEntity floor, BookingEntity booking)
 {
     if (floor.CountEmptyPlaces >= 1 || booking.ArrivalTime < floor.NextEmptyPlace)
     {
         return(false);
     }
     return(false);
 }
Ejemplo n.º 15
0
        private BookingEntity InsertEntity(BookingSpecialSaveDto bookingSpecialDto)
        {
            BookingEntity entity = Mapper.Map <BookingEntity>(bookingSpecialDto);

            entity.Id     = 0;
            entity.Status = BookingStatusEnum.Special;
            return(entity);
        }
Ejemplo n.º 16
0
        public void DeleteSpecialBooking(int id)
        {
            BookingEntity entity = _bookingRepository.GetById(id);

            ValidateSpecialBooking(entity);

            _bookingRepository.Delete(entity);
        }
Ejemplo n.º 17
0
 private void AssertPaymentConfirmationSuccessFull(BookingEntity entity,
                                                   Mock <INotificationService> notificationMock, Mock <IRepository <BookingEntity> > repoMock)
 {
     Assert.AreEqual(BookingStatusEnum.Paid, entity.Status);
     Assert.IsTrue(!string.IsNullOrWhiteSpace(entity.Code));
     repoMock.Verify(x => x.Save(entity), Times.Once());
     notificationMock.Verify(x => x.SendBookingCodeAsync(entity), Times.Once());
 }
Ejemplo n.º 18
0
        public async Task <BookingEntity> Add(BookingEntity element)
        {
            await _coworkingDbContext.bookingEntities.AddAsync(element);

            await _coworkingDbContext.SaveChangesAsync();

            return(element);
        }
Ejemplo n.º 19
0
 public virtual bool CheckBookingNo(BookingEntity booking, CarEntity car)
 {
     if (booking.CarKey == car.CarKey)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 20
0
        public PrepareBookingPaymentDto PrepareBookingPayment(int id, CurrentUser user)
        {
            BookingEntity booking = _bookingRepository.GetById(id);

            ValidateBookingForAction(booking, user.UserId, x => x.Status == BookingStatusEnum.Unpaid);

            return(_payService.PrepareBookingPaymnent(booking));
        }
Ejemplo n.º 21
0
        public async Task <BookingEntity> Add(BookingEntity entity)
        {
            await _coworkingDbContext.Bookings.AddAsync(entity);

            await _coworkingDbContext.SaveChangesAsync();

            return(entity);
        }
Ejemplo n.º 22
0
        public async Task <bool> ResendBookingCode(int id, CurrentUser user)
        {
            BookingEntity booking = _bookingRepository.GetById(id);

            ValidateBookingForAction(booking, user.UserId, x => x.Status == BookingStatusEnum.Paid);

            return(await _notificationService.SendBookingCodeAsync(booking));
        }
Ejemplo n.º 23
0
        public void DeleteBooking(IBooking booking)
        {
            BookingEntity entity = (BookingEntity)booking;

            entity.Deleted = true;

            bookings.Remove(booking);
        }
Ejemplo n.º 24
0
        public void CancelBooking(int id, CurrentUser user)
        {
            BookingEntity booking = _bookingRepository.GetById(id);

            ValidateBookingForAction(booking, user.UserId, x => x.Status != BookingStatusEnum.Paid && x.Status != BookingStatusEnum.Canceled);

            booking.Status = BookingStatusEnum.Canceled;
            _bookingRepository.Save(booking);
        }
Ejemplo n.º 25
0
        public IBooking CreateBooking(ISupplier supplier, ICustomer customer, string sale, int bookingNumber,
                                      DateTime startDate, DateTime endDate)
        {
            BookingEntity booking = new BookingEntity(supplier, customer, sale, bookingNumber, startDate, endDate);

            bookings.Add(booking);

            return(booking);
        }
        public IHttpActionResult Post(BookingEntity value)
        {
            if (ModelState.IsValid)
            {
                var bookingReference = _bprocessor.CreateBooking(value);
                return(Ok(bookingReference));
            }

            return(BadRequest());
        }
Ejemplo n.º 27
0
        public BookingSpecialDto SaveSpecialBooking(BookingSpecialSaveDto bookingSpecialDto)
        {
            BookingEntity entity = bookingSpecialDto.Id.Value <= 0
                                ? InsertEntity(bookingSpecialDto)
                                : UpdateEntity(bookingSpecialDto);

            _bookingRepository.Save(entity);

            return(Mapper.Map <BookingSpecialDto>(entity));
        }
Ejemplo n.º 28
0
 public void DeletBooking(BookingEntity booking)
 {
     if (booking.ID != 0)
     {
         _bookingRepository.Detele(booking.ID);
     }
     else
     {
         throw new Exception("Nothing to delete!");
     }
 }
Ejemplo n.º 29
0
 public static Booking ToService(this BookingEntity entity)
 {
     return(entity != null ? new Booking {
         Id = entity.Id, Comments = entity.Comments,
         CustomerName = entity.CustomerName, EndDate = entity.EndDate,
         FieldName = entity.FieldName,
         PhoneNumber = entity.PhoneNumber,
         StartDate = entity.StartDate,
         CreationDate = entity.CreationDate, IsActive = entity.IsActive
     } : null);
 }
Ejemplo n.º 30
0
        public async Task <BookingEntity> Update(int idEntity, BookingEntity updateEntity)
        {
            var entity = await Get(idEntity);

            entity.RentWorkSpace = updateEntity.RentWorkSpace;

            _coworkingDbContext.Bookings.Update(entity);
            await _coworkingDbContext.SaveChangesAsync();

            return(entity);
        }