Ejemplo n.º 1
0
        public IActionResult GetAllType()
        {
            var type = _service.GetAllTypes();
            List <PTWTypeDto> Dto = new List <PTWTypeDto>();

            foreach (var item in type)
            {
                PTWTypeDto Dtos = _mapper.Map <PTWTypeDto>(item);
                Dto.Add(Dtos);
            }
            return(Ok(Dto));
        }
Ejemplo n.º 2
0
        public IActionResult UpdateType(int id, [FromBody] PTWTypeDto typeDto)
        {
            var type = _mapper.Map <PTWType>(typeDto);

            try
            {
                _service.Update(id, type);
                return(Ok());
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Ejemplo n.º 3
0
        public IActionResult AddType([FromBody] PTWTypeDto typeDto)
        {
            var type = _mapper.Map <PTWType>(typeDto);

            try
            {
                _service.Create(type);
                return(Ok("Records Added Successfully.. "));
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex.Message }));
            }
        }
Ejemplo n.º 4
0
        ///TODO- need to add this profile fields in db and api
        public IActionResult GetTypeByID(int id)
        {
            var type = _service.GetById(id);

            if (type == null)
            {
                return(new UnauthorizedResult());
            }

            PTWTypeDto typeDto = new PTWTypeDto()
            {
                ID   = type.ID,
                Type = type.Type
            };

            return(Ok(typeDto));
        }