示例#1
0
 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);
     }
 }
示例#2
0
 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);
     }
 }
示例#3
0
 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));
     }
 }
示例#4
0
 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));
     }
 }
示例#5
0
 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));
     }
 }