public async Task <Organizator> CreateNewOrganizator(OrganizatorResource resource) { try { Organizator organizator = new Organizator() { Name = resource.Name }; await _organizatorRepository.AddOrganizator(organizator); var createAdminResult = await _administratorService.CreateNewAdministrator(resource.CreatorId, organizator.OrganizatorId); if (!createAdminResult) { return(null); } var updateUserRole = await _userRepository.UpdateUserRoleToAdmin(resource.CreatorId); if (!updateUserRole) { return(null); } return(organizator); } catch (Exception e) { return(null); } }
public ActionResult CreateNewAdministrator([FromBody] Administrator administratorData) { if (administratorData != null) { var newAdministrator = service.CreateNewAdministrator(administratorData); if (newAdministrator != null) { return(Json(newAdministrator)); } } return(Json("something went wrong")); }