public async Task <JsonResult> UpdatePishkhanInfoById(TblPishkhan model)
        {
            if (ModelState.IsValid)
            {
                var result    = _service.TblPishkhan.Update(model);
                var _complete = _service.Complete();
                var complete  = await _complete;


                if (result && complete > 0)
                {
                    return(Json(new { pm = "ok" }));
                }
                else
                {
                    return(Json(new { pm = "خطا در سیستم" }));
                }
            }
            else
            {
                return(Json(new { pm = "لطفا اطلاعات را به درسیتی وارد نمایید" }));
            }
        }
        public async Task <IActionResult> AddPishkhan(TblPishkhan model)
        {
            if (ModelState.IsValid)
            {
                var result = _service.TblPishkhan.Add(model);

                if (await result)
                {
                    var save = _service.Complete();

                    if (await save > 0)
                    {
                        ModelState.Clear();
                        model.Name = "";
                        ViewBag.pm = "ok";
                        return(View());
                    }
                    else
                    {
                        ModelState.AddModelError(string.Empty, "خطا در ذخیره اطلاعات در دیتا بیس");
                        return(View(model));
                    }
                }

                else
                {
                    ModelState.AddModelError(string.Empty, "خطا در ثبت اولیه");
                    return(View(model));
                }
            }

            else
            {
                ModelState.AddModelError(string.Empty, "لطفا اطلاعات را به درستی وارد نمایید.");
                return(View(model));
            }
        }
        //متدی برای پر کردت ویو مدال که هر بار لازم بود صداش کنیم
        private async Task <AddViewModels> FillAddModel()
        {
            AddViewModels model = new AddViewModels();



            try
            {
                //Fill the model
                var _agent       = _user.GetAgentListAsync();
                var _pishkhan    = _service.TblPishkhan.GetAll();
                var _supervisior = _service.TblSupervisior.GetAll();
                var _setting     = _service.TblSetting.GetFirst();

                var agent       = await _agent;
                var pishkhan    = await _pishkhan;
                var supervisior = await _supervisior;

                //Fill Agent
                foreach (var item in agent)
                {
                    AgentListViewModels vm = new AgentListViewModels();
                    vm.AgentID = item.AgentID;
                    vm.Email   = item.Email;
                    vm.ID      = item.Id;
                    vm.Name    = item.Name;

                    model.AgentVM.Add(vm);
                }


                //Fill Pishkhan
                foreach (var item in pishkhan)
                {
                    TblPishkhan vm = new TblPishkhan();
                    vm.ID            = item.ID;
                    vm.Name          = item.Name;
                    vm.Pishkhan_Code = item.Pishkhan_Code;

                    model.PishkhanVm.Add(vm);
                }

                //Fill Supervisior
                foreach (var item in supervisior)
                {
                    TblSupervisior vm = new TblSupervisior();
                    vm.ID   = item.ID;
                    vm.Name = item.Name;

                    model.SupervisiorVm.Add(vm);
                }


                //Fill PaymentType
                var paymentType = Enum.GetValues(typeof(PaymentType)).Cast <PaymentType>().Select(p => p.ToString()).ToList();
                model.PaymentType = paymentType;

                //Insurance Status
                var insuranceStatus = Enum.GetValues(typeof(InsuranceStatus)).Cast <InsuranceStatus>().Select(p => p.ToString()).ToList();
                model.InsuranceStatus = insuranceStatus;


                //Fill Insurance Number
                var setting = await _setting;
                model.LifeInsuranceVM.InsuranceNumber_Code           = setting.InsuranceNumber_Code;
                model.LifeInsuranceVM.InsuranceNumber_CenterCode     = setting.InsuranceNumber_CenterCode;
                model.LifeInsuranceVM.InsuranceNumber_GarardadNumber = setting.InsuranceNumber_GarardadNumber;
                model.LifeInsuranceVM.InsuranceNumber_Year           = setting.InsuranceNumber_Year;
            }
            catch { }

            return(model);
        }