Exemple #1
0
        public async Task <IHttpActionResult> SetOrderPickupDateTime(OrderPickupTimeViewModel order)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Invalid order pickup date or time."));
            }
            var dobi = GetDobiInformationFromToken();

            if (dobi == null || string.IsNullOrEmpty(dobi.DobiId))
            {
                return(BadRequest("Invalid User."));
            }
            var ack = await _orderBusiness.SetOrderPickupDateTime(order, dobi);

            if (!ack)
            {
                return(Ok(new ResponseModel <string>(ResponseStatus.BadRequest, null, "Pickup time and date not set.")));
            }
            return(Ok(new ResponseModel <string>(ResponseStatus.Ok, "", "Order pickup date time set successfully.")));
        }
Exemple #2
0
        public async Task <bool> SetOrderPickupDateTime(OrderPickupTimeViewModel order, DobiBasicInformation dobi)
        {
            try
            {
                var orderPickupDate = Utilities.GetMillisecondFromDate(order.PickupDate);
                var result          = await _orderRepository.SetOrderPickupDateTime(orderPickupDate, order.PickupTime, order.ServiceId, dobi);

                if (result == null)
                {
                    return(false);
                }
                var messageSend = await _userMessageBusiness.AddUserMessage(result.OrderBy.UserId, (int)MessageType.OrderAcknowledge, result.ServiceId);

                if (messageSend == null)
                {
                    return(false);
                }
                var notification = new Notification
                {
                    Type             = (int)NotificationType.SetOrderPickupTime,
                    MessageId        = messageSend,
                    Title            = Constants.ACK_MESSAGE_TITLE,
                    Text             = string.Format(Constants.ACK_MESSAGE_TEXT, order.ServiceId),
                    SenderUserName   = dobi.Name,
                    SenderUserId     = dobi.DobiId,
                    ReceiverUserName = result.OrderBy.Name,
                    ReceiverUserId   = result.OrderBy.UserId,
                    Status           = (int)NotificationStatus.NotSent,
                    NotificationId   = Guid.NewGuid().ToString()
                };
                var notificationAdd = await _notificationRepository.AddNotification(notification);

                return(notificationAdd);
            }
            catch (Exception ex)
            {
                throw new Exception("Error setting pickup date time" + ex);
            }
        }