public async Task <ActionResult <DataResponse <ProfileExtModel> > > Delete([FromRoute] string ID)
        {
            DataResponse <ProfileExtModel> response = new DataResponse <ProfileExtModel>();
            ProfileExtModel _DTO     = null;
            string          errorMsg = String.Empty;

            try
            {
                if (ID != null)
                {
                    // Update country
                    var _country = await _unitOfWork.Profiles.DeleteProfile(ID).ConfigureAwait(false);

                    if (_country == null)
                    {
                        response.Code        = ResponseCode.FAILED;
                        response.Description = ResponseDescription.FAILED;
                        response.Message     = errorMsg;
                        response.Data        = _DTO;
                        return(NotFound(response));
                    }

                    int done = await _unitOfWork.CompleteAsync().ConfigureAwait(false);

                    if (done > 0)
                    {
                        //_DTO = _mapper.Map<ProfileExtModel>(_country);

                        response.Code        = ResponseCode.SUCCESS;
                        response.Description = ResponseDescription.SUCCESS;
                        response.Message     = "Profile deleted";
                        response.Data        = _DTO;
                        return(NoContent());
                    }
                }

                response.Code        = ResponseCode.FAILED;
                response.Description = ResponseDescription.FAILED;
                response.Message     = "Invalid country ID";
                response.Data        = _DTO;
                return(BadRequest(response));
            }
            catch (Exception ex)
            {
                Guid _ErrorCode = Guid.NewGuid();
                Log.Error("Fatal Error [{ErrorCode}]: {Message}", _ErrorCode, ex.Message);
                response.Code        = ResponseCode.SYSTEM_ERROR;
                response.Description = ResponseDescription.SYSTEM_ERROR;
                response.Message     = $"System Error: Something went wrong here! Kindly contact the support with this error code [{_ErrorCode}]";
                response.Data        = _DTO;
                return(BadRequest(response));
            }
        }
        public async Task <ActionResult <DataResponse <ProfileExtModel> > > GetByID([FromRoute] string ID)
        {
            DataResponse <ProfileExtModel> response = new DataResponse <ProfileExtModel>();
            ProfileExtModel _DTO = null;

            try
            {
                var _country = await _unitOfWork.Profiles.GetAsync(ID).ConfigureAwait(false);

                if (_country == null)
                {
                    response.Code        = ResponseCode.NOT_FOUND;
                    response.Description = ResponseDescription.NOT_FOUND;
                    response.Message     = "Profile not found";
                    response.Data        = _DTO;
                    return(NotFound(response));
                }

                _DTO = _mapper.Map <ProfileExtModel>(_country);

                response.Code        = ResponseCode.SUCCESS;
                response.Description = ResponseDescription.SUCCESS;
                response.Message     = null;
                response.Data        = _DTO;
                return(Ok(response));
            }
            catch (Exception ex)
            {
                Guid _ErrorCode = Guid.NewGuid();
                Log.Error("Fatal Error [{ErrorCode}]: {Message}", _ErrorCode, ex.Message);
                response.Code        = ResponseCode.SYSTEM_ERROR;
                response.Description = ResponseDescription.SYSTEM_ERROR;
                response.Message     = $"System Error: Something went wrong here! Kindly contact the support with this error code [{_ErrorCode}]";
                response.Data        = _DTO;
                return(BadRequest(response));
            }
        }
        public async Task <ActionResult <DataResponse <ProfileExtModel> > > Put([FromBody] ProfileModel model, [FromRoute] string ID)
        {
            DataResponse <ProfileExtModel> response = new DataResponse <ProfileExtModel>();
            ProfileExtModel _DTO     = null;
            string          errorMsg = String.Empty;

            try
            {
                if (ModelState.IsValid && model != null)
                {
                    // Custom Validations
                    if (!ProfileFactory.ValidateModel(model, ID, out errorMsg))
                    {
                        response.Code        = ResponseCode.FAILED;
                        response.Description = ResponseDescription.FAILED;
                        response.Message     = errorMsg;
                        response.Data        = _DTO;
                        return(BadRequest(response));
                    }

                    // Check Entity Exist
                    //if (_unitOfWork.Profiles.CheckExist(model.Name, model.Code, out errorMsg, ID))
                    //{
                    //    response.Code = ResponseCode.FAILED;
                    //    response.Description = ResponseDescription.FAILED;
                    //    response.Message = errorMsg;
                    //    response.Data = _DTO;
                    //    return BadRequest(response);
                    //}

                    // Generate entity
                    var _entity = ProfileFactory.Create(model, null, null);

                    // Create user
                    var _country = await _unitOfWork.Profiles.UpdateAsync(_entity).ConfigureAwait(false);

                    int done = await _unitOfWork.CompleteAsync().ConfigureAwait(false);

                    if (done > 0)
                    {
                        _DTO = _mapper.Map <ProfileExtModel>(_country);

                        response.Code        = ResponseCode.SUCCESS;
                        response.Description = ResponseDescription.SUCCESS;
                        response.Message     = null;
                        response.Data        = _DTO;
                        return(Ok(_DTO));
                    }
                }

                response.Code        = ResponseCode.FAILED;
                response.Description = ResponseDescription.FAILED;
                response.Message     = "Invalid user input";
                response.Data        = _DTO;
                return(BadRequest(response));
            }
            catch (Exception ex)
            {
                Guid _ErrorCode = Guid.NewGuid();
                Log.Error("Fatal Error [{ErrorCode}]: {Message}", _ErrorCode, ex.Message);
                response.Code        = ResponseCode.SYSTEM_ERROR;
                response.Description = ResponseDescription.SYSTEM_ERROR;
                response.Message     = $"System Error: Something went wrong here! Kindly contact the support with this error code [{_ErrorCode}]";
                response.Data        = _DTO;
                return(BadRequest(response));
            }
        }