public async Task <UniversityModel> Add(UpsertUniversityModel model) { var university = new University(model.Name, model.City); await repository.Add(university); await repository.SaveChanges(); return(mapper.Map <UniversityModel>(university)); }
public async Task <ActionResult> Add([Bind(Include = "Name, Description")] University university) { if (ModelState.IsValid) { _universityRepository.Add(university); await _universityRepository.Commit(); return(RedirectToAction("Index")); } return(View(university)); }
public UniversityDTO Add(UniversityDTO uni) { UNIVERSITY uniToAdd, addedUni; UniversityDTO retVal; retVal = null; if (CheckHelper.IsFilled(uni)) { try { uniToAdd = transformer.TransformFromDTO(-1, uni); addedUni = uniRepository.Add(uniToAdd); if (CheckHelper.IsFilled(addedUni)) { retVal = transformer.TransformToDTO(addedUni); } } catch (Exception) { } } return(retVal); }
public void Add(TEntity entity) { repo.Add(entity); }
/// <summary> /// این متد رکورد سازمان مرکزی را به همراه واحد مرکز استان ، دانشگاه ، احراز هویت ، شخص ، کاربر /// و نقش مدیر دانشگاه را ثبت می کند و نقش را به کاربر مربوطه انتساب می دهد /// </summary> /// <param name="modelRegisterProgram"></param> /// <returns></returns> public bool RegisterProgramUniversity(RegisterProgramUniversityModel modelRegisterProgram) { try { _unitOfWork.BeginTransaction(); //ثبت رکورد سازمان مرکزی var centralOrganization = new CentralOrganization { Name = "سازمان مرکزی" }; _centralOrganizationRepository.Add(centralOrganization); //var baseRegisterProgramModel = new BaseRegisterProgramModel //{ // RoleType = RoleType.AdminCentral, // Name = "مدیر سازمان", // NationalCode = "1111111111", // Password = "******", // OrganName = "سازمان مرکزی", // UserName = "******", // LicenceCode = "1111111111" //}; //if (!AddUserAdminAutomatic(centralOrganization.Id, AuthenticationType.AdminCentral, RoleType.AdminCentral, baseRegisterProgramModel)) // throw new Exception(""); //ثبت رکورد واحد سازمان var branchProvince = new BranchProvince { CentralOrganizationId = centralOrganization.Id, Name = "واحد مرکز استان" }; _branchProvinceRepository.Add(branchProvince); //baseRegisterProgramModel.RoleType = RoleType.AdminBranch; //baseRegisterProgramModel.Name = "مدیر واحد استان"; //baseRegisterProgramModel.NationalCode = "2222222222"; //baseRegisterProgramModel.Password = "******"; //baseRegisterProgramModel.OrganName = "واحد مرکز استان"; //baseRegisterProgramModel.UserName = "******"; //baseRegisterProgramModel.LicenceCode = "2222222222"; //if(!AddUserAdminAutomatic(branchProvince.Id, AuthenticationType.AdminBranch, RoleType.AdminBranch, baseRegisterProgramModel)) // throw new Exception(""); //ثبت رکورد دانشگاه var university = new University { BranchProvinceId = branchProvince.Id, Name = modelRegisterProgram.OrganName, Address = modelRegisterProgram.Address, Code = modelRegisterProgram.Code, Phone = modelRegisterProgram.Phone }; _universityRepository.Add(university); var setting = new Settings { UniversityId = university.Id, CommissionNumberRepetitions = 1, CouncilNumberRepetitions = 1, Ordinal = Ordinal.Ordinal }; _settingsRepository.Add(setting); //_universityRepository.Add(university); if (!AddUserAdminAutomatic(university.Id, AuthenticationType.AdminUniversity, RoleType.AdminUniversity, modelRegisterProgram)) { throw new Exception(""); } _unitOfWork.SaveChanges(); _unitOfWork.CommitTransaction(); return(true); } catch (Exception ex) { _unitOfWork.Rollback(); return(false); } }
public IActionResult AddUniversity([FromBody] University model) { Uni_repo.Add(model); return(new OkObjectResult(new { UniversityID = model.UniversityId })); }
public IActionResult AddQualification([FromBody] University model) { uni_repo.Add(model); return(new OkObjectResult(new { UniversityId = model.UniversityId })); }
public void CreateUniversity(University university) { universityRepository.Add(university); }