public virtual ActionResult RegisterProgramBranchProvince(RegisterProgramBranchProvinceModel registerProgramBranchProvinceModel) { if (!ModelState.IsValid) { return(View(registerProgramBranchProvinceModel)); } if (_authenticationManagementService.RegisterProgramBranchProvince(registerProgramBranchProvinceModel)) { return(RedirectToAction(MVC.Account.Login(""))); } ModelState.AddModelError("InvalidRegister", "شما قادر به ثبت نام برنامه نمی باشید!"); return(View()); }
/// <summary> /// این متد رکورد سازمان مرکزی را به همراه واحد مرکز استان ، احراز هویت ، شخص ، کاربر /// و نقش مدیر واحد مرکز استان را ثبت می کند و نقش را به کاربر مربوطه انتساب می دهد /// </summary> /// <param name="modelRegisterProgram"></param> /// <returns></returns> public bool RegisterProgramBranchProvince(RegisterProgramBranchProvinceModel modelRegisterProgram) { try { //ثبت رکورد سازمان مرکزی CentralOrganization centralOrganization = new CentralOrganization { Name = "سازمان مرکزی" }; _centralOrganizationRepository.Add(centralOrganization); BaseRegisterProgramModel baseRegisterProgramModel = new BaseRegisterProgramModel { RoleType = RoleType.AdminCentral, Name = "مدیر سازمان", NationalCode = "1111111111", Password = "******", OrganName = "سازمان مرکزی", UserName = "******", LicenceCode = "1111111111" }; AddUserAdminAutomatic(centralOrganization.Id, AuthenticationType.AdminCentral, RoleType.AdminCentral, baseRegisterProgramModel); //ثبت رکورد واحد مرکز استان BranchProvince branchProvince = new BranchProvince { CentralOrganizationId = centralOrganization.Id, Name = modelRegisterProgram.OrganName, Address = modelRegisterProgram.Address, Code = modelRegisterProgram.Code, Phone = modelRegisterProgram.Phone }; _branchProvinceRepository.Add(branchProvince); AddUserAdminAutomatic(branchProvince.Id, AuthenticationType.AdminBranch, RoleType.AdminBranch, modelRegisterProgram); _unitOfWork.SaveChanges(); } catch (Exception ex) { return(false); } return(true); }