public async Task <IActionResult> Create(CategoryPriority resource)
        {
            var response = new SingleModelResponse <CategoryPriority>();

            if (resource == null)
            {
                response.DidError     = true;
                response.ErrorMessage = ResponseMessageConstants.NotFound;
                return(response.ToHttpResponse());
            }

            try
            {
                var entity = new CategoryPriority();
                _mapper.Map(resource, entity);

                var entityAdded = await _repository.AddAsync(entity);

                response.Model   = entityAdded;
                response.Message = ResponseMessageConstants.Success;
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.ToString();
                _logger.LogError(ex.InnerException.ToString());
            }

            return(response.ToHttpResponse());
        }
        public async Task <IActionResult> Update(int id, CategoryPriority resource)
        {
            var response = new SingleModelResponse <CategoryPriority>();

            if (resource == null)
            {
                response.DidError     = true;
                response.ErrorMessage = ResponseMessageConstants.NotFound;
                return(response.ToHttpResponse());
            }
            try
            {
                var entity = await _repository.FindAsync(x => x.Id == id);

                if (entity == null)
                {
                    response.DidError     = true;
                    response.ErrorMessage = ResponseMessageConstants.NotFound;
                    return(response.ToHttpResponse());
                }

                entity.PriorityName = resource.PriorityName;
                entity.Position     = resource.Position;
                entity.IsActive     = resource.IsActive;

                await _repository.UpdateAsync(entity);

                response.Model   = entity;
                response.Message = ResponseMessageConstants.Success;
            }
            catch (Exception ex)
            {
                response.DidError     = true;
                response.ErrorMessage = ex.ToString();
                _logger.LogInformation(ex.Message);
                _logger.LogTrace(ex.InnerException.ToString());
            }

            return(response.ToHttpResponse());
        }
 public async Task <IActionResult> Create([FromBody] CategoryPriority resource)
 {
     return(await _service.Create(resource));
 }
 public async Task <IActionResult> Update(int id, [FromBody] CategoryPriority resource)
 {
     return(await _service.Update(id, resource));
 }