public TopicDTO(Topic topic) { Id = topic.Id; Name = topic.Name; Types = new List <TypeDTO>(); foreach (Type type in topic.Types) { TypeDTO typeDTO = new TypeDTO(type); Types.Add(typeDTO); } }
public override bool Equals(Object obj) { if ((obj == null) || !this.GetType().Equals(obj.GetType())) { return(false); } else { TypeDTO typeDTO = (TypeDTO)obj; return(this.Id == typeDTO.Id); } }
public IActionResult Get(Guid id) { try { Type type = typeLogic.Get(id); TypeDTO typeToReturn = new TypeDTO(type); return(Ok(typeToReturn)); } catch (BusinessLogicException e) { return(NotFound(e.Message)); } catch (DataAccessException e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public IActionResult Post([FromBody] TypeDTO typeDTO) { try { Type typeToCreate = typeDTO.ToEntity(); Type createdType = typeLogic.Create(typeToCreate); TypeDTO typeToReturn = new TypeDTO(createdType); return(Ok(typeToReturn)); } catch (BusinessLogicException e) { return(BadRequest(e.Message)); } catch (DataAccessException e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }
public IActionResult Get() { try { IEnumerable <Type> typesInBD = typeLogic.GetAll(); List <TypeDTO> typesToReturn = new List <TypeDTO>(); foreach (Type type in typesInBD) { TypeDTO tm = new TypeDTO(type); typesToReturn.Add(tm); } return(Ok(typesToReturn)); } catch (BusinessLogicException e) { return(BadRequest(e.Message)); } catch (DataAccessException e) { return(StatusCode(StatusCodes.Status500InternalServerError, e.Message)); } }