public async Task <ActionResult <OrganizationView> > EditOrganizationAsync([FromBody] OrganizationEditRequest organizationEditRequest) { var currentUserId = GetCurrentUserId(); try { var editedOrg = await organizationManager.EditAsync(organizationEditRequest, currentUserId); return(Ok(await editedOrg .ProjectTo <OrganizationView>(mapper.ConfigurationProvider) .SingleAsync())); } catch (ArgumentNullException ane) { logger.LogDebug(ane.Message + "\n" + ane.StackTrace); return(NotFound($"Can't find organization {organizationEditRequest.Id}")); } catch (ArgumentException ae) { logger.LogDebug(ae.Message + "\n" + ae.StackTrace); return(BadRequest($"Organization with name '{organizationEditRequest.Name}' already exists")); } catch (MethodAccessException mae) { logger.LogDebug(mae.Message + "\n" + mae.StackTrace); logger.LogDebug($"User {currentUserId} has no rights to edit organization {organizationEditRequest.Id}"); return(Forbid(JwtBearerDefaults.AuthenticationScheme, CookieAuthenticationDefaults.AuthenticationScheme)); } catch (Exception ex) { logger.LogDebug(ex.Message + "\n" + ex.StackTrace); return(StatusCode(500)); } }