IEnumerator Upload()
    {
        WWWForm form = new WWWForm();

        var dt = DateTime.ParseExact(toggleGroup.GetActive().GetComponentInChildren <Text>().text, "dd-MMM-yyyy", CultureInfo.InvariantCulture);

        BookedDate bookedDate = new BookedDate(dt.ToString("MM-dd-yyyy", CultureInfo.InvariantCulture), false);
        //BookedDate bookedDate = new BookedDate(toggleGroup.GetActive().GetComponentInChildren<Text>().text, true);

        string bookedDateJson = JsonUtility.ToJson(bookedDate);

        form.AddField("BookedDate", bookedDateJson);

        UnityWebRequest www = UnityWebRequest.Post(NetworkManager.Instance.url + "/bookings/" + bookingId + "/bookeddate", form);

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log(www.downloadHandler.text);
        }
    }
Пример #2
0
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(BookedDate.ToShortDateString());
            sb.Append(" Room: ");
            sb.Append(RoomID);
            return(sb.ToString());
        }
Пример #3
0
 public void Save(BookedDate entity)
 {
     if (entity.Id == default)
     {
         context.Entry(entity).State = EntityState.Added;
     }
     else
     {
         context.Entry(entity).State = EntityState.Modified;
     }
     context.SaveChanges();
 }
Пример #4
0
        public async Task <BookingCartItem> AddToCart(BookedDate bookedDate)
        {
            if (bookedDate == null)
            {
                return(null);
            }

            var bookingCartItem = BookingCartItem.Create(CartId, bookedDate.Id, userId: CurrentUserId);

            database.BookingCartItemRepository.Add(bookingCartItem);

            return(await database.Complete() ? bookingCartItem : null);
        }
        private void SetDueDate()
        {
            switch (TypeOfService.ToLower())
            {
            case "oil service":
                DueDate = BookedDate.AddDays(2);
                break;

            case "water service":
                DueDate = BookedDate.AddDays(1);
                break;

            default:
                DueDate = BookedDate.AddDays(3);
                break;
            }
        }
Пример #6
0
        public async Task <BookedDate> BookDate(DateTime startDate, DateTime endDate, string offerId)
        {
            var offer = await database.OfferRepository.Get(offerId);

            if (offer == null)
            {
                return(null);
            }

            var currentUser = await profileService.GetCurrentUser();

            if (currentUser.Id == offer.CreatorId)
            {
                Alertify.Push("You are owner of this offer", AlertType.Warning);
                return(null);
            }

            if (!bookingValidationService.IsBookingDateAvailable(startDate, endDate, offer))
            {
                Alertify.Push("This date is already booked", AlertType.Warning);
                return(null);
            }

            if (currentUser != null && bookingValidationService.HasUserAnotherBookedDate(currentUser, offer.Id))
            {
                Alertify.Push("You have already booked this offer", AlertType.Warning);
                return(null);
            }

            var bookedDate = BookedDate.Create(startDate, endDate);

            offer.BookedDates.Add(bookedDate);

            if (currentUser != null)
            {
                currentUser.BookedDates.Add(bookedDate);
            }

            return(await database.Complete() ? bookedDate : null);
        }
Пример #7
0
    IEnumerator UpdateConfirmCR()
    {
        WWWForm    form       = new WWWForm();
        BookedDate bookedDate = new BookedDate(GetBookingsManager.Instance.theBookings.bookings[GetBookingsManager.Instance.selectedIndex].bookedDate.proposedDate, true);

        string bookedDateJson = JsonUtility.ToJson(bookedDate);

        form.AddField("BookedDate", bookedDateJson);

        UnityWebRequest www = UnityWebRequest.Post(NetworkManager.Instance.url + "/bookings/" + GetBookingsManager.Instance.theBookings.bookings[GetBookingsManager.Instance.selectedIndex]._id + "/bookeddate", form);

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log(www.downloadHandler.text);
        }
    }
Пример #8
0
 public bool IsPermittedToCancelBooking(BookedDate bookedDate, string currentUserId)
 => !(bookedDate.UserId != null && bookedDate.UserId != currentUserId && currentUserId != bookedDate.Offer.CreatorId);