public BranchOfficeManagementModel BranchOfficeManagementDetail(int BranchOfficeId)
        {
            BranchOffices     result            = ent.BranchOffices.Where(x => x.BranchOfficeId == BranchOfficeId).FirstOrDefault();
            View_AgentDetails Agentadmindetails = _agentdetailsprovider.GetAgentAdminUser(BranchOfficeId);

            BranchOfficeManagementModel model = new BranchOfficeManagementModel();

            model.BranchOfficeId    = result.BranchOfficeId;
            model.BranchOfficeId    = result.BranchOfficeId;
            model.BranchOfficeCode  = result.BranchOfficeCode;
            model.BranchOffice      = result.BranchOfficeName;
            model.NativeCountry     = result.NativeCountryId;
            model.NativeCountryName = result.Countries.CountryName;
            model.Zone         = result.ZoneId;
            model.ZoneName     = result.Zones.ZoneName;
            model.District     = result.DistrictId;
            model.DistrictName = result.Districts.DistrictName;
            model.Address      = result.Address;
            model.Phone        = result.Phone;
            model.Email        = result.Email;
            model.Fax          = result.FaxNo;
            model.PanNo        = result.PanNo;
            model.Web          = result.Web;
            model.status       = Convert.ToInt32(result.Status);
            model.TimeZone     = result.TimeZoneId;
            model.isSystem     = result.isSystem;
            model.CreatedBy    = result.CreatedBy;
            model.CreatedDate  = result.CreatedDate;
            model.UpdatedBy    = result.UpdatedBy;
            model.UpdatedDate  = result.UpdatedDate;


            View_BranchDetails BranchUserDetail = GetBranchUserDetails(BranchOfficeId);

            if (BranchUserDetail != null)
            {
                model.FullName        = BranchUserDetail.FullName;
                model.UserName        = BranchUserDetail.UserName;
                model.UserEmail       = BranchUserDetail.Email;
                model.UserAddress     = BranchUserDetail.UserAddress;
                model.UserPhone       = BranchUserDetail.Phone;
                model.MobileNo        = BranchUserDetail.MobileNumber;
                model.Password        = BranchUserDetail.Password;
                model.ConfirmPassword = BranchUserDetail.Password;
            }

            return(model);
        }
        public View_AgentDetails GetAgentAdminUser(int AgentId)
        {
            View_AgentDetails SuperAgentdetails = db.View_AgentDetails.Where(uu => (uu.AgentId == AgentId && uu.UserTypeId == 2)).SingleOrDefault();

            return(SuperAgentdetails);
        }