示例#1
0
        public ActionResult GetUser(int UserId)
        {
            try
            {
                var response = AsyncHelpers.RunSync <JObject>(() => ApiCall.CallApi("api/Admin/GetUser", User, null, true, false, null, "User_Id=" + UserId));

                UserDataViewModel model = null;

                if (response is Error)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.InternalServerError, "Internal Server Error"));
                }
                else
                {
                    model = response.GetValue("result").ToObject <UserDataViewModel>();
                }

                if (model.ProfilePictureUrl == null || model.ProfilePictureUrl == "")
                {
                    model.ProfilePictureUrl = "UserImages/Default.png";
                }
                //foreach (var subscription in model.UserSubscriptions)
                //{
                //    subscription.Box.CategoryName = Utility.GetBoxCategoryName(subscription.Box.BoxCategory_Id);

                //}

                //foreach (var order in model.Orders)
                //{
                //    order.PaymentMethodName = Utility.GetPaymentMethodName(order.PaymentMethod);
                //    order.PaymentStatusName = Utility.GetPaymentStatusName(order.PaymentStatus);
                //}


                //model.UserAddresses = model.UserAddresses.Where(x => x.IsDeleted == false).ToList();
                //model.PaymentCards = model.PaymentCards.Where(x => x.IsDeleted == false).ToList();

                //foreach (var notification in model.Notifications)
                //{
                //    notification.StatusName = notification.Status == 0 ? "Unread" : "Read";
                //}
                model.SetSharedData(User);

                return(View("User", model));
            }
            catch (Exception ex)
            {
                return(new HttpStatusCodeResult(Utility.LogError(ex), "Internal Server Error"));
            }
        }