コード例 #1
0
        public ActionResult Edit(int?id, AgentModel model, int[] ChkProductId, FormCollection fc)
        {
            model.AgentId     = id == null ? 0 : id.Value;
            model.UpdatedBy   = LogedUserId;
            model.UpdatedDate = CurrentDate;
            model.EmailId     = model.EmailId.Trim(';');
            if (_rep.CheckEditDuplicateEmail(model.Email, id.Value))
            {
                TempData["ActionResponse"] = "Registration failed! Email already exists, please re-enter and try again";
                _model = _rep.Detail(id, out _res);

                foreach (var AsociatedProductOfAgent in _model.AgentProductList)
                {
                    ViewData[AsociatedProductOfAgent.ProductName] = new SelectList(_rep.GetAllRolesListonProductWise(AsociatedProductOfAgent.ProductId), "RoleName", "RoleName", "");
                }
                ViewData["AgentBank"]        = _agentdetailsprovider.GetAgentBankList(id.Value);
                ViewData["Countrylist"]      = new SelectList(_rep.GetCountry(), "CountryId", "CountryName", _rep.GetCountryInfo(_model.NativeCountryId));
                ViewData["AgentZone"]        = new SelectList(_rep.GetZoneList(), "ZoneId", "ZoneName", _model.ZoneId);
                ViewData["AgentDistrict"]    = new SelectList(_rep.GetDistrictListbyZoneId(Convert.ToInt32(_model.ZoneId)), "DistrictId", "DistrictName", Convert.ToInt32(_model.DistrictId));
                ViewData["Status"]           = new SelectList(_rep.GetStatus(), "id", "Name", 1);
                ViewData["AgentTypes"]       = new SelectList(_rep.GetAgentType(), "AgentTypeId", "AgentTypeName");
                ViewData["agentClass"]       = new SelectList(_rep.GetAgentClass(), "AgentClassId", "AgentClassName");
                ViewData["Banks"]            = new SelectList(_rep.GetbankInformation(), "BankId", "BankName");
                ViewData["BankBranches"]     = new SelectList(_rep.GetbankBranchInformation(), "BankBranchId", "BranchName");
                ViewData["BankAccountTypes"] = new SelectList(_rep.GetbankAccountType(), "BankAccountTypeId", "AccountTypeName");
                ViewData["TimeZones"]        = new SelectList(_rep.GetTimeZoneList(), "RecordID", "DisplayName");
                _model.ReferredByList        = _rep.GetAllGetSalesAgentList();
                _model.MEsNameList           = _rep.GetAllGetSalesAgentList();
                return(View(_model));
            }
            else
            {
                if (!string.IsNullOrEmpty(model.MobileNo) && !_rep.CheckEditDuplicateMobileNumber(model.MobileNo, id.Value))
                {
                    TempData["ActionResponse"] = "Registration failed! Mobile Number already exists, please re-enter and try again";
                    _model = _rep.Detail(id, out _res);

                    foreach (var AsociatedProductOfAgent in _model.AgentProductList)
                    {
                        ViewData[AsociatedProductOfAgent.ProductName] = new SelectList(_rep.GetAllRolesListonProductWise(AsociatedProductOfAgent.ProductId), "RoleName", "RoleName", "");
                    }
                    ViewData["AgentBank"]        = _agentdetailsprovider.GetAgentBankList(id.Value);
                    ViewData["Countrylist"]      = new SelectList(_rep.GetCountry(), "CountryId", "CountryName", _rep.GetCountryInfo(_model.NativeCountryId));
                    ViewData["AgentZone"]        = new SelectList(_rep.GetZoneList(), "ZoneId", "ZoneName", _model.ZoneId);
                    ViewData["AgentDistrict"]    = new SelectList(_rep.GetDistrictListbyZoneId(Convert.ToInt32(_model.ZoneId)), "DistrictId", "DistrictName", Convert.ToInt32(_model.DistrictId));
                    ViewData["Status"]           = new SelectList(_rep.GetStatus(), "id", "Name", 1);
                    ViewData["AgentTypes"]       = new SelectList(_rep.GetAgentType(), "AgentTypeId", "AgentTypeName");
                    ViewData["agentClass"]       = new SelectList(_rep.GetAgentClass(), "AgentClassId", "AgentClassName");
                    ViewData["Banks"]            = new SelectList(_rep.GetbankInformation(), "BankId", "BankName");
                    ViewData["BankBranches"]     = new SelectList(_rep.GetbankBranchInformation(), "BankBranchId", "BranchName");
                    ViewData["BankAccountTypes"] = new SelectList(_rep.GetbankAccountType(), "BankAccountTypeId", "AccountTypeName");
                    ViewData["TimeZones"]        = new SelectList(_rep.GetTimeZoneList(), "RecordID", "DisplayName");
                    _model.ReferredByList        = _rep.GetAllGetSalesAgentList();
                    _model.MEsNameList           = _rep.GetAllGetSalesAgentList();
                    return(View(_model));
                }

                else
                {
                    _res = _rep.Edit(id, model, ChkProductId, fc);
                    TempData["InfoMessage"] = _res.ActionMessage;
                    if (_res.ErrNumber == 0)
                    {
                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        _model = _rep.Detail(id, out _res);
                        _model.ReferredByList   = _rep.GetAllGetSalesAgentList();
                        TempData["InfoMessage"] = _res.ActionMessage;
                        if (_res.ErrNumber == 0)
                        {
                            foreach (var AsociatedProductOfAgent in _model.AgentProductList)
                            {
                                ViewData[AsociatedProductOfAgent.ProductName] = new SelectList(_rep.GetAllRolesListonProductWise(AsociatedProductOfAgent.ProductId), "RoleName", "RoleName", "");
                            }
                            ViewData["AgentBank"]        = _agentdetailsprovider.GetAgentBankList(id.Value);
                            ViewData["Countrylist"]      = new SelectList(_rep.GetCountry(), "CountryId", "CountryName", _rep.GetCountryInfo(_model.NativeCountryId));
                            ViewData["AgentZone"]        = new SelectList(_rep.GetZoneList(), "ZoneId", "ZoneName", _model.ZoneId);
                            ViewData["AgentDistrict"]    = new SelectList(_rep.GetDistrictListbyZoneId(Convert.ToInt32(_model.ZoneId)), "DistrictId", "DistrictName", Convert.ToInt32(_model.DistrictId));
                            ViewData["Status"]           = new SelectList(_rep.GetStatus(), "id", "Name", 1);
                            ViewData["AgentTypes"]       = new SelectList(_rep.GetAgentType(), "AgentTypeId", "AgentTypeName");
                            ViewData["agentClass"]       = new SelectList(_rep.GetAgentClass(), "AgentClassId", "AgentClassName");
                            ViewData["Banks"]            = new SelectList(_rep.GetbankInformation(), "BankId", "BankName");
                            ViewData["BankBranches"]     = new SelectList(_rep.GetbankBranchInformation(), "BankBranchId", "BranchName");
                            ViewData["BankAccountTypes"] = new SelectList(_rep.GetbankAccountType(), "BankAccountTypeId", "AccountTypeName");
                            ViewData["TimeZones"]        = new SelectList(_rep.GetTimeZoneList(), "RecordID", "DisplayName");
                            return(View(_model));
                        }
                        else
                        {
                            return(RedirectToAction("Index"));
                        }
                    }
                }
            }
        }