コード例 #1
0
        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);
            }
        }
コード例 #2
0
 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"));
 }