Пример #1
0
        public virtual async Task <IHttpActionResult> Get(ODataQueryOptions <TOrder> options)
        {
            ODataQuerySettings settings = new ODataQuerySettings()
            {
            };
            var result = await _service.GetAsync();

            IQueryable query       = options.ApplyTo(result.AsQueryable(), settings);
            var        pagedResult = new PageResult <TOrder>(query as IQueryable <TOrder>, Request.ODataProperties().NextLink, Request.ODataProperties().TotalCount);

            return(Content(HttpStatusCode.OK, pagedResult));
        }
Пример #2
0
        public async Task <IHttpActionResult> post(NotifyAlert <TKey> alert)
        {
            var id = alert.Id;
            //convert alert key to status enum
            CurrentOrderStatus status = (CurrentOrderStatus)Enum.Parse(typeof(CurrentOrderStatus), alert.Key);

            var order = await _service.GetAsync(id);

            if (order == null)
            {
                return(new ContentErrorResult(Request, HttpStatusCode.NotFound, "No order found for the notification request"));
            }
            if (order.OrderStatus.Status == status)
            {
                return(new ContentErrorResult(Request, HttpStatusCode.BadRequest, "Submitted order status is the same as the current status"));
            }
            alert.PhoneNumber = order.BillingAddress.PhoneNumber;
            alert.Email       = order.Email;
            alert.TrackingUrl = order.TrackingUrl;

            var orderAlertTasks = _taskList.Tasks.Where(x => x.TaskType == NotifyTaskType.OrderAlert);

            //run tasks
            orderAlertTasks.ToList().ForEach(x => x.RunAsync(alert));

            //save status, notification to order
            await _service.UpdateStatusAsync(id, status, new OrderNotification
            {
                Key   = alert.Key,
                Value = alert.Value,
                Date  = DateTime.Now
            });

            return(Ok(alert));
        }
Пример #3
0
        public async Task <IHttpActionResult> post(NotifyAlert <TKey> alert)
        {
            var id    = alert.Id;
            var order = await _service.GetAsync(id);

            if (order == null)
            {
                return(new ContentErrorResult(Request, HttpStatusCode.NotFound, "Error: No Order found for the notification request"));
            }
            alert.PhoneNumber = order.BillingAddress.PhoneNumber;
            alert.Email       = order.Email;
            alert.TrackingUrl = order.TrackingUrl;

            var orderAlertTasks = _taskList.Tasks.Where(x => x.TaskType == NotifyTaskType.OrderAlert);

            //run tasks
            orderAlertTasks.ToList().ForEach(x => x.RunAsync(alert));

            //save notification to order
            await _service.AddNotificationAsync(id, new OrderNotification
            {
                Key   = alert.Key,
                Value = alert.Value,
                Date  = DateTime.Now
            });

            return(Ok(alert));
        }
Пример #4
0
        public async Task <IActionResult> GetOrder([FromRoute] int id)
        {
            AdminOrderReponseModel result = await _orderService.GetAsync(id);

            return(Ok(result));
        }