Exemplo n.º 1
0
 public MerchantSettingModels GetDetail(string id)
 {
     try
     {
         MerchantSettingModels model = new MerchantSettingModels();
         //===================================
         var listStoreSetting = _factory.GetListDataPayment(id, CurrentUser.ListOrganizationId);
         if (listStoreSetting != null && listStoreSetting.Count > 0)
         {
             var storeSetting = listStoreSetting.Where(x => x.Value.ToLower().Equals("true")).FirstOrDefault();
             if (storeSetting != null)
             {
                 model.StoreID   = storeSetting.StoreId;
                 model.StoreName = storeSetting.StoreName;
             }
         }
         //List<string> ListOrganizationId = new List<string>();
         //ListOrganizationId.Add(id);
         //var listStore = _factory.GetListStoreForMerchant(ListOrganizationId, CurrentUser.ListStoreID);
         //ViewBag.ListStore = listStore;
         //===============
         var listCompnay = _factory.GetListDataWallet(id, CurrentUser.ListOrganizationId);
         if (listCompnay != null && listCompnay.Count > 0)
         {
             listCompnay = listCompnay.OrderBy(x => x.CompanyName).ToList();
             int offset = 0;
             listCompnay.ForEach(x =>
             {
                 x.IsActive = (x.Value.ToLower().Equals("true")) ? true : false;
                 x.OffSet   = offset++;
             });
             model.ListCompnayShow = listCompnay;
         }
         model.Id = id;
         return(model);
     }
     catch (Exception ex)
     {
         _logger.Error("MerchantSetting_Detail: " + ex);
         return(null);
     }
 }
Exemplo n.º 2
0
        public bool UpdateWallet(MerchantSettingModels model, List <string> ListOrganizations, ref string msg)
        {
            try
            {
                MerchantSettingApiModels paraBody = new MerchantSettingApiModels();
                paraBody.AppKey      = Commons.AppKey;
                paraBody.AppSecret   = Commons.AppSecret;
                paraBody.CreatedUser = Commons.CreateUser;

                paraBody.ListCompany = model.ListCompany;
                //paraBody.MerchantID = model.Id;
                //paraBody.ListOrganizations = ListOrganizations;
                //====================
                var result = (ResponseApiModels)ApiResponse.Post <ResponseApiModels>(Commons.SaveMerchantSetting_WalletSave, null, paraBody);
                if (result != null)
                {
                    if (result.Success)
                    {
                        return(true);
                    }
                    else
                    {
                        _logger.Error(result.Message);
                        msg = result.Message;
                        return(false);
                    }
                }
                else
                {
                    _logger.Error(result);
                    return(false);
                }
            }
            catch (Exception e)
            {
                _logger.Error("Updated_MerchantSettingWallet: " + e);
                return(false);
            }
        }
Exemplo n.º 3
0
        public PartialViewResult Edit(string id)
        {
            MerchantSettingModels model = GetDetail(id);

            return(PartialView("_Edit", model));
        }
Exemplo n.º 4
0
        public ActionResult Edit(MerchantSettingModels model)
        {
            try
            {
                if (string.IsNullOrEmpty(model.StoreID))
                {
                    ModelState.AddModelError("StoreID", _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey("Please choose store"));
                }
                if (!ModelState.IsValid)
                {
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    return(PartialView("_Edit", model));
                }

                model.StoreSetting         = new StoreSettingModels();
                model.StoreSetting.StoreId = model.StoreID;
                model.StoreSetting.Value   = "true";

                //==============
                //List<string> ListOrganizationId = new List<string>();
                //ListOrganizationId.Add(model.Id);
                //var listStore = _factory.GetListStoreForMerchant(ListOrganizationId, CurrentUser.ListStoreID);
                //ViewBag.ListStore = listStore;

                //==========
                string msg = "";
                //Payment
                var result = _factory.UpdatePayment(model, CurrentUser.ListOrganizationId, ref msg);
                if (result)
                {
                    //Wallet
                    if (model.ListCompnayShow != null && model.ListCompnayShow.Count > 0)
                    {
                        model.ListCompnayShow.ForEach(x =>
                        {
                            x.Value = x.IsActive.ToString();
                        });
                    }
                    model.ListCompany = model.ListCompnayShow;
                    //============
                    result = _factory.UpdateWallet(model, CurrentUser.ListOrganizationId, ref msg);
                    if (result)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("StoreID", msg);
                        Response.StatusCode = (int)HttpStatusCode.BadRequest;
                        return(PartialView("_Edit", model));
                    }
                }
                else
                {
                    ModelState.AddModelError("StoreID", msg);
                    Response.StatusCode = (int)HttpStatusCode.BadRequest;
                    return(PartialView("_Edit", model));
                }
            }
            catch (Exception ex)
            {
                _logger.Error("MerchantSetting_Edit: " + ex);
                return(new HttpStatusCodeResult(400, ex.Message));
            }
        }
Exemplo n.º 5
0
        public new PartialViewResult View(string id)
        {
            MerchantSettingModels model = GetDetail(id);

            return(PartialView("_View", model));
        }