public ActionResult OrderReceived(int orderId)
        {
            var request = new OrderReceivedRequest { OrderId = orderId };
            var response = this.orderService.OrderReceived(request);
            var result = response.ConvertToOrderViewModel();

            var jsonNetResult = new JsonNetResult
            {
                Formatting = (Formatting)Newtonsoft.Json.Formatting.Indented,
                Data = result
            };
            return jsonNetResult;
        }
Beispiel #2
0
        /// <summary>
        /// Updates order status to received
        /// </summary>
        /// <param name="request">
        /// The request.
        /// </param>
        /// <returns>
        /// The <see cref="OrderReceivedResponse"/>.
        /// </returns>
        public OrderReceivedResponse OrderReceived(OrderReceivedRequest request)
        {
            try
            {
                var order = this.orderRepository.GetOrderById(request.OrderId);
                order.SetAsReceived();
                var updatedOrder = this.orderRepository.UpdateOrder(order);
                if (order.User.Activated)
                {
                    if (updatedOrder.ReceivedDate.HasValue)
                    {
                        var body = string.Format(
                            order.User.Profile.GetEmailResourceString("OrderReceivedEmailBody"),
                            updatedOrder.Retailer.Name,
                            updatedOrder.Id,
                            updatedOrder.ReceivedDate.Value.ToShortDateString(),
                            order.User.Profile.GetFullName());
                        this.emailService.SendMail(
                            EmailResources.EmailActivationFrom,
                            order.User.Email,
                            order.User.Profile.GetEmailResourceString("OrderReceivedEmailSubject"),
                            body);
                    }
                }

                var response = updatedOrder.ConvertToOrderReceivedResponse();
                response.Message = CommonResources.OrderStatusChangedToReceived;
                response.MessageType = MessageType.Success;
                return response;
            }
            catch (Exception ex)
            {
                this.Logger.Error(CommonResources.OrderReceivedErrorMessage, ex);
                return new OrderReceivedResponse { MessageType = MessageType.Error, ErrorCode = ex.Message };
            }
        }