Exemplo n.º 1
0
        /*Trongntn 10-03-2017*/
        /// <summary>
        ///
        /// </summary>
        /// <param name="CustomerID"></param>
        /// <returns></returns>
        public CustomerDetailModels GetInfoLite(string CustomerID)
        {
            CustomerDetailModels model          = new CustomerDetailModels();
            Customermodel        customerdetail = new Customermodel();
            MerchantDTO          merchentdetail = new MerchantDTO();

            try
            {
                GetInfoRequestModels paraBody = new GetInfoRequestModels();
                paraBody.ID = CustomerID;
                NSLog.Logger.Info("GetInfoLite_Request: ", paraBody);
                //====================
                var     result = (NSApiResponse)ApiResponse.Post <NSApiResponse>(Commons.ClientSideMyProfileGetInfo, null, paraBody);
                dynamic data   = result.Data;
                //====customer detail
                var customer  = data["CustomerDetail"];
                var lstObject = JsonConvert.SerializeObject(customer);
                customerdetail = JsonConvert.DeserializeObject <Customermodel>(lstObject);
                NSLog.Logger.Info("GetInfoLite_Response: ", customerdetail);
                //======merchant detail
                var merchant  = data["MerchantDetail"];
                var merchants = JsonConvert.SerializeObject(merchant);
                merchentdetail = JsonConvert.DeserializeObject <MerchantDTO>(merchants);
                NSLog.Logger.Info("GetInfoLite_Response: ", merchentdetail);
                //--------------
                model.CustomerDetail = customerdetail;
                model.MerchantDetail = merchentdetail;
                return(model);
            }
            catch (Exception e)
            {
                NSLog.Logger.Error("GetInfoLite_Fail: ", e);
                return(model);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public CustomerDetailModels GetDetail(string ID)
        {
            CustomerDetailModels item  = new CustomerDetailModels();
            MerchantModels       item2 = new MerchantModels();

            try
            {
                CustomerRequest paraBody = new CustomerRequest();
                paraBody.ID = ID;

                NSLog.Logger.Info("CustomerDetail Request: ", paraBody);

                var     result      = (NSApiResponse)ApiResponse.Post <NSApiResponse>(Commons.customerAPIGetDetail, null, paraBody);
                dynamic data        = result.Data;
                var     lstDataRaw  = data["CustomerDetail"];
                var     lstDataRaw2 = data["MerchantDetail"];
                var     lstObject   = JsonConvert.SerializeObject(lstDataRaw);
                var     lstObject2  = JsonConvert.SerializeObject(lstDataRaw2);
                item  = JsonConvert.DeserializeObject <CustomerDetailModels>(lstObject);
                item2 = JsonConvert.DeserializeObject <MerchantModels>(lstObject2);
                if (item != null)
                {
                    item.Birthday    = CommonHelper.ConvertToLocalTime(item.Birthday);
                    item.Anniversary = CommonHelper.ConvertToLocalTime(item.Anniversary);
                    item.JoinedDate  = CommonHelper.ConvertToLocalTime(item.JoinedDate);
                }
                if (item2 != null)
                {
                    item.MerchantName = item2.Name;
                }
                lstDataRaw = data["ListReceipt"];
                lstObject  = JsonConvert.SerializeObject(lstDataRaw);
                var ListReceipt = JsonConvert.DeserializeObject <List <OrderModels> >(lstObject);

                item.ListReceipt = ListReceipt;
                if (item.ListReceipt != null)
                {
                    item.ListReceipt.ForEach(x =>
                    {
                        x.CreatedDate = CommonHelper.ConvertToLocalTime(x.CreatedDate);
                        x.PaidTime    = CommonHelper.ConvertToLocalTime(x.PaidTime);
                    });
                }
                NSLog.Logger.Info("CustomerGetDetail", item);

                return(item);
            }
            catch (Exception e)
            {
                NSLog.Logger.Error("CustomerGetDetail_Fail", e);
                return(item);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public CustomerDetailModels GetInfo(string id)
        {
            CustomerDetailModels         model          = new CustomerDetailModels();
            Customermodel                customerdetail = new Customermodel();
            List <PurchaseReceiptModels> listoder       = new List <PurchaseReceiptModels>();
            MerchantDTO merchentdetail = new MerchantDTO();

            try
            {
                GetInfoRequestModels paraBody = new GetInfoRequestModels();
                paraBody.ID = id;
                NSLog.Logger.Info("GetInfoPersonalDetail_Request: ", paraBody);

                // Reseller => merchantDetail = null | listReceipt > 0
                // Customer => listReceipt == 1

                //====================
                var     result = (NSApiResponse)ApiResponse.Post <NSApiResponse>(Commons.ClientSideMyProfileGetInfo, null, paraBody);
                dynamic data   = result.Data;
                //====customer detail
                var customer  = data["CustomerDetail"];
                var lstObject = JsonConvert.SerializeObject(customer);
                customerdetail = JsonConvert.DeserializeObject <Customermodel>(lstObject);
                NSLog.Logger.Info("GetInfoCustomerDetail_Response: ", customerdetail);
                //======merchant detail
                var merchant  = data["MerchantDetail"];
                var merchants = JsonConvert.SerializeObject(merchant);
                merchentdetail = JsonConvert.DeserializeObject <MerchantDTO>(merchants);
                NSLog.Logger.Info("GetInfoMerchantDetail_Response: ", merchentdetail);
                //====list order
                var order     = data["ListReceipt"];
                var lstorders = JsonConvert.SerializeObject(order);
                listoder = JsonConvert.DeserializeObject <List <PurchaseReceiptModels> >(lstorders);
                NSLog.Logger.Info("GetInfoListOder_Response: ", listoder);
                //--------------------
                model.CustomerDetail = customerdetail;
                model.MerchantDetail = merchentdetail;
                model.ListReceipt    = listoder;
                NSLog.Logger.Info("GetInfoPersonalDetail_Response: ", model);
                return(model);
            }
            catch (Exception e)
            {
                NSLog.Logger.Error("GetInfoPersonalDetail_Fail: ", e);
                return(model);
            }
        }
Exemplo n.º 4
0
        public ActionResult Edit()
        {
            CustomerDetailModels customer = new CustomerDetailModels();
            Customermodel        model    = new Customermodel();

            customer       = _myProfileFactory.GetInfo(CurrentUser.UserId);
            model          = customer.CustomerDetail;
            model.ImageURL = string.IsNullOrEmpty(model.ImageURL) ? _ImgDummyCustomer : model.ImageURL;
            GetListCountry();
            if (model != null)
            {
                return(PartialView("_Edit", model));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="model"></param>
        /// <param name="msg"></param>
        /// <returns></returns>
        public bool CreateOrEdit(CustomerDetailModels model, ref string msg)
        {
            try
            {
                CustomerRequest paraBody = new CustomerRequest();
                model.Birthday          = CommonHelper.ConvertToUTCTime(model.Birthday);
                model.Anniversary       = CommonHelper.ConvertToUTCTime(model.Anniversary);
                model.JoinedDate        = CommonHelper.ConvertToUTCTime(model.JoinedDate);
                paraBody.CustomerDetail = model;
                paraBody.CreatedUser    = model.CreateUser;

                NSLog.Logger.Info("CustomerCreateOrEdit Request: ", paraBody);

                //====================
                var result = (NSApiResponse)ApiResponse.Post <NSApiResponse>(Commons.customerAPICreateOrEdit, null, paraBody);
                if (result != null)
                {
                    if (result.Success)
                    {
                        return(true);
                    }
                    else
                    {
                        msg = result.Message;
                        NSLog.Logger.Info("CustomerCreateOrEdit", result.Message);
                        return(false);
                    }
                }
                else
                {
                    NSLog.Logger.Info("CustomerCreateOrEdit", result);
                    return(false);
                }
            }
            catch (Exception e)
            {
                NSLog.Logger.Error("CustomerCreateOrEdit_Fail", e);
                return(false);
            }
        }
Exemplo n.º 6
0
        public ActionResult Index()
        {
            try
            {
                CustomerDetailModels model = new CustomerDetailModels();
                model = _myProfileFactory.GetInfo(CurrentUser.UserId);
                //Reseller
                if (model.MerchantDetail == null && model.ListReceipt != null && model.ListReceipt.Count > 0)
                {
                    if (model.ListReceipt != null && model.ListReceipt.Count > 0)
                    {
                        model.ListReceipt.ForEach(x =>
                        {
                            x.ListReceipt.ForEach(z =>
                            {
                                z.CreatedDate = CommonHelper.ConvertToLocalTime(z.CreatedDate);
                                z.PaidTime    = CommonHelper.ConvertToLocalTime(z.PaidTime);
                                //paymend
                                z.sPaidByMethod = string.Join("<br/>", z.PaidByMethod);
                                //status
                                if (z.OrderStatus == (byte)Commons.EOrderStatus.Completed)
                                {
                                    z.sOrderStatus = Commons.EOrderStatus.Completed.ToString();
                                }
                                else if (z.OrderStatus == (byte)Commons.EOrderStatus.Full_Refunded)
                                {
                                    z.sOrderStatus = Commons.EOrderStatus.Full_Refunded.ToString();
                                }
                                else if (z.OrderStatus == (byte)Commons.EOrderStatus.Half_Refunded)
                                {
                                    z.sOrderStatus = Commons.EOrderStatus.Half_Refunded.ToString();
                                }
                                z.CurrencySymbol = CurrencySymbol;
                                //-----------------
                                z.CustomerEmail = x.CustomerEmail;
                                z.MerchantName  = x.MerchantName;
                            });
                        });
                    }
                }
                else //Customer
                {
                    if (model.ListReceipt.Count == 1)
                    {
                        model.ListReceipt[0].ListReceipt.ForEach(x =>
                        {
                            x.CreatedDate = CommonHelper.ConvertToLocalTime(x.CreatedDate);
                            x.PaidTime    = CommonHelper.ConvertToLocalTime(x.PaidTime);
                            //paymend
                            x.sPaidByMethod = string.Join("<br/>", x.PaidByMethod);
                            //status
                            if (x.OrderStatus == (byte)Commons.EOrderStatus.Completed)
                            {
                                x.sOrderStatus = Commons.EOrderStatus.Completed.ToString();
                            }
                            else if (x.OrderStatus == (byte)Commons.EOrderStatus.Full_Refunded)
                            {
                                x.sOrderStatus = Commons.EOrderStatus.Full_Refunded.ToString();
                            }
                            else if (x.OrderStatus == (byte)Commons.EOrderStatus.Half_Refunded)
                            {
                                x.sOrderStatus = Commons.EOrderStatus.Half_Refunded.ToString();
                            }
                            x.CurrencySymbol = CurrencySymbol;
                        });
                    }
                }

                //==============
                if (model.MerchantDetail != null)
                {
                    if (model.MerchantDetail.Street != null)
                    {
                        model.MerchantDetail.Address = model.MerchantDetail.Street + ", ";
                    }
                    if (model.MerchantDetail.City != null)
                    {
                        model.MerchantDetail.Address += model.MerchantDetail.City + ", ";
                    }
                    if (model.MerchantDetail.Country != null)
                    {
                        model.MerchantDetail.Address += model.MerchantDetail.Country;
                    }
                }
                //Image
                model.CustomerDetail.ImageURL = string.IsNullOrEmpty(model.CustomerDetail.ImageURL) ? _ImgDummyCustomer : model.CustomerDetail.ImageURL;
                if (model.CustomerDetail != null)
                {
                    if (model.CustomerDetail.ImageURL != null)
                    {
                        CurrentUser.ImageUrl = model.CustomerDetail.ImageURL;
                        CurrentUser.UserName = model.CustomerDetail.Name;
                    }
                    return(View("ShowUserInformation", model));
                }
                else
                {
                    return(RedirectToAction("Index", "Home"));
                }
            }
            catch (Exception ex)
            {
                NSLog.Logger.Error("PersonalInformation_Index:", ex);
                return(new HttpStatusCodeResult(400, ex.Message));
            }
        }