public async Task <ActionResult> Create([FromBody] SpecializationDTO dto) { try { var spec = dto.ConceptSpecialization(); var created = await manager.CreateAsync(spec); return(Ok(SpecializationDTO.From(created))); } catch (FormatException fe) { logger.LogError("Malformed Specialization:{@Specialization} Error:{Error}", dto, fe.Message); return(BadRequest(CRUDError.From("Malformed Specialization.UniversalId."))); } catch (ArgumentException ae) { logger.LogError("Invalid create Specialization model. Model:{@Model} Error:{Error}", dto, ae.Message); return(BadRequest(CRUDError.From($"{nameof(Specialization)} is missing or incomplete."))); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception e) { logger.LogError("Failed to create Specialization:{@Specialization} Error:{Error}", dto, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <NetworkEndpointDTO> > CreateEndpoint([FromBody] NetworkEndpointDTO state) { try { var e = state.NetworkEndpoint(); var created = await manager.CreateEndpointAsync(e); var payload = created.NetworkEndpointDTO(); return(Ok(payload)); } catch (UriFormatException ue) { logger.LogError("Invalid address in create NetworkEndpoint model. Model:{@Model} Error:{Error}", state, ue.Message); return(BadRequest(CRUDError.From($"{nameof(NetworkEndpointDTO)} address is malformed."))); } catch (ArgumentException ae) { logger.LogError("Invalid create NetworkEndpoint model. Model:{@Model} Error:{Error}", state, ae.Message); return(BadRequest(CRUDError.From($"{nameof(NetworkEndpointDTO)} is missing, incomplete, or malformed."))); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode)); } catch (Exception ex) { logger.LogError("Failed to create NetworkEndpoint. Model:{@Model} Error:{Error}", state, ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <ConceptEvent> > Create([FromBody] ConceptEvent conceptEvent) { try { if (conceptEvent == null) { return(BadRequest(CRUDError.From("ConceptEvent is missing."))); } if (string.IsNullOrWhiteSpace(conceptEvent.UiDisplayEventName)) { return(BadRequest(CRUDError.From("ConceptEvent.UiDisplayEventName is required."))); } var created = await evService.Create(conceptEvent); return(Ok(created)); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception e) { logger.LogError("Could not create ConceptEvent:{@ConceptEvent}. Error:{Error}", conceptEvent, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <ConceptDTO> > Update(Guid id, [FromBody] ConceptDTO o) { try { if (o == null) { return(BadRequest(CRUDError.From("Concept missing."))); } o.Id = id; var c = o.Concept(); var updated = await cService.Update(c); return(Ok(new ConceptDTO(updated))); } catch (LeafDbException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception ex) { logger.LogError("Could not update concept. Concept:{@Concept}, Error:{Error}", o, ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <AdminConceptDTO> > Update(Guid id, [FromBody] AdminConceptDTO o) { try { if (o != null) { o.Id = id; } var c = o.Concept(); var updated = await manager.UpdateAsync(c); return(Ok(new AdminConceptDTO(updated))); } catch (ArgumentException ae) { logger.LogError("Invalid update Concept model. Model:{@Model} Error:{Error}", o, ae.Message); return(BadRequest(CRUDError.From($"{nameof(AdminConcept)} is missing or incomplete."))); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception ex) { logger.LogError("Failed to update concept. Concept:{@Concept} Error:{Error}", o, ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult> Update(int id, [FromBody] ConceptSqlSet conceptSqlSet) { try { if (conceptSqlSet == null) { return(BadRequest(CRUDError.From("ConceptSqlSet is missing."))); } if (string.IsNullOrWhiteSpace(conceptSqlSet.SqlSetFrom)) { return(BadRequest(CRUDError.From("ConceptSqlSet.SqlSetFrom is required."))); } conceptSqlSet.Id = id; var updated = await setService.Update(conceptSqlSet); if (updated == null) { return(NotFound()); } return(Ok(updated)); } catch (LeafDbException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception e) { logger.LogError("Could not update ConceptSqlSet:{@ConceptSqlSet}. Error:{Error}", conceptSqlSet, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult> Update(int id, [FromBody] ConceptSqlSet conceptSqlSet) { try { if (conceptSqlSet != null) { conceptSqlSet.Id = id; } var updated = await manager.UpdateAsync(conceptSqlSet); if (updated == null) { return(NotFound()); } return(Ok(updated)); } catch (ArgumentException ae) { logger.LogError("Invalid update ConceptSqlSet model. Model:{@Model} Error:{Error}", conceptSqlSet, ae.Message); return(BadRequest(CRUDError.From($"{nameof(ConceptSqlSet)} is missing or incomplete."))); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception e) { logger.LogError("Failed to update ConceptSqlSet:{@ConceptSqlSet}. Error:{Error}", conceptSqlSet, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult> Update(Guid id, [FromBody] SpecializationDTO dto) { try { if (dto == null) { return(BadRequest(CRUDError.From("Specialization is missing."))); } if (dto.SpecializationGroupId == default) { return(BadRequest(CRUDError.From("Specialization.SpecializationGroupId is required."))); } if (string.IsNullOrWhiteSpace(dto.UiDisplayText)) { return(BadRequest(CRUDError.From("Specialization.UiDisplayText is required."))); } if (string.IsNullOrWhiteSpace(dto.SqlSetWhere)) { return(BadRequest(CRUDError.From("Specialization.SqlSetWhere is required."))); } dto.Id = id; var spec = dto.ConceptSpecialization(); var updated = await specializationService.Update(spec); if (updated == null) { return(NotFound()); } return(Ok(SpecializationDTO.From(updated))); } catch (FormatException fe) { logger.LogError("Malformed Specialization:{@Specialization} Error:{Error}", dto, fe.Message); return(BadRequest(CRUDError.From("Malformed Specialization.UniversalId."))); } catch (LeafDbException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception e) { logger.LogError("Could not update Specialization:{@Specialization} Error:{Error}", dto, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <SpecializationGroupDTO> > Update(int id, [FromBody] SpecializationGroupDTO dto) { try { if (dto == null) { return(BadRequest(CRUDError.From("SpecializationGroup is missing."))); } if (dto.SqlSetId == default) { return(BadRequest(CRUDError.From("SpecializationGroup.SqlSetId is missing."))); } if (string.IsNullOrWhiteSpace(dto.UiDefaultText)) { return(BadRequest(CRUDError.From("SpecializationGroup.UiDefaultText is missing."))); } dto.Id = id; var group = dto.SpecializationGroup(); var updated = await sgService.Update(group); if (updated == null) { return(NotFound()); } return(Ok(SpecializationGroupDTO.From(updated))); } catch (FormatException fe) { logger.LogError("Malformed SpecializationGroup:{@SpecializationGroup} Error:{Error}", dto, fe.Message); return(BadRequest(CRUDError.From(fe.Message))); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception e) { logger.LogError("Could not update SpecializationGroup:{@SpecializationGroup} Error:{Error}", dto, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <SpecializationGroupDTO> > Create([FromBody] SpecializationGroupDTO dto) { try { if (dto == null) { return(BadRequest(CRUDError.From("SpecializationGroup is missing."))); } if (dto.SqlSetId == default) { return(BadRequest(CRUDError.From("SpecializationGroup.SqlSetId is missing."))); } if (string.IsNullOrWhiteSpace(dto.UiDefaultText)) { return(BadRequest(CRUDError.From("SpecializationGroup.UiDefaultText is missing."))); } if (dto.Specializations?.Any(s => string.IsNullOrWhiteSpace(s.SqlSetWhere) || string.IsNullOrWhiteSpace(s.UiDisplayText)) ?? false) { return(BadRequest(CRUDError.From("Malformed Specializations."))); } var group = dto.SpecializationGroup(); var created = await sgService.Create(group); return(Ok(SpecializationGroupDTO.From(created))); } catch (FormatException fe) { logger.LogError("Malformed SpecializationGroup:{@SpecializationGroup} Error:{Error}", dto, fe.Message); return(BadRequest(CRUDError.From(fe.Message))); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception e) { logger.LogError("Could not create SpecializationGroup:{@SpecializationGroup} Error:{Error}", dto, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <DatasetQueryCategoryDeleteResponse> > DeleteAsync(int id) { try { var result = await manager.DeleteCategoryAsync(id); if (!result.Ok) { return(Conflict(new DatasetQueryCategoryDeleteResponse(result))); } return(Ok()); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception ex) { log.LogError("Failed to delete DatasetQueryCategory. Id:{Id} Error:{Error}", id, ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <ConceptDeleteResult> > Delete(Guid id) { try { var result = await cService.Delete(id); if (!result.Ok) { return(Conflict(new ConceptDeleteResponse(result))); } return(Ok()); } catch (LeafDbException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception ex) { logger.LogError("Could not delete concept. Id:{Id} Error:{Error}", id, ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <SpecializationGroupDeleteResponse> > Delete(int id) { try { var result = await manager.DeleteAsync(id); if (!result.Ok) { return(Conflict(SpecializationGroupDeleteResponse.From(result))); } return(Ok()); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception e) { logger.LogError("Failed to delete SpecializationGroup. Id:{Id} Error:{Error}", id, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <SpecializationGroupDTO> > Update(int id, [FromBody] SpecializationGroupDTO dto) { try { if (dto != null) { dto.Id = id; } var group = dto.SpecializationGroup(); var updated = await manager.UpdateAsync(group); if (updated == null) { return(NotFound()); } return(Ok(SpecializationGroupDTO.From(updated))); } catch (FormatException fe) { logger.LogError("Malformed SpecializationGroup:{@SpecializationGroup} Error:{Error}", dto, fe.Message); return(BadRequest(CRUDError.From(fe.Message))); } catch (ArgumentException ae) { logger.LogError("Invalid update SpecializationGroup model. Model:{@Model} Error:{Error}", dto, ae.Message); return(BadRequest(CRUDError.From($"{nameof(SpecializationGroup)} is missing or incomplete."))); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception e) { logger.LogError("Failed to update SpecializationGroup:{@SpecializationGroup} Error:{Error}", dto, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <NetworkIdentity> > UpsertIdentity([FromBody] NetworkIdentity identity) { try { var updated = await manager.UpdateIdentityAsync(identity); return(Ok(updated)); } catch (ArgumentException ae) { logger.LogError("Invalid update NetworkIdentity model. Model:{@Model} Error:{Error}", identity, ae.Message); return(BadRequest(CRUDError.From($"{nameof(NetworkIdentity)} is missing, incomplete, or malformed."))); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode)); } catch (Exception ex) { logger.LogError("Failed to updated NetworkIdentity. Model:{@Model} Error:{Error}", identity, ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult> Delete(Guid id) { try { var deleted = await manager.DeleteAsync(id); if (deleted == null) { return(NotFound()); } return(Ok()); } catch (ArgumentException ae) { logger.LogError("Invalid Specialization Id. Id:{Id} Error:{Error}", id, ae.Message); return(BadRequest(CRUDError.From("Invalid id value."))); } catch (Exception ex) { logger.LogError("Failed to delete Specialization. Id:{Id} Error:{Error}", id, ex.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }
public async Task <ActionResult <ConceptSqlSet> > Create([FromBody] ConceptSqlSet conceptSqlSet) { try { var created = await manager.CreateAsync(conceptSqlSet); return(Ok(created)); } catch (ArgumentException ae) { logger.LogError("Invalid create ConceptSqlSet model. Model:{@Model} Error:{Error}", conceptSqlSet, ae.Message); return(BadRequest(CRUDError.From($"{nameof(ConceptSqlSet)} is missing or incomplete."))); } catch (LeafRPCException le) { return(StatusCode(le.StatusCode, CRUDError.From(le.Message))); } catch (Exception e) { logger.LogError("Failed to create ConceptSqlSet:{@ConceptSqlSet}. Error:{Error}", conceptSqlSet, e.ToString()); return(StatusCode(StatusCodes.Status500InternalServerError)); } }