Пример #1
0
        public async Task <Response <string> > InsertAsync(UserDTO model)
        {
            var response = new Response <string>();

            try
            {
                var resp = _mapper.Map <User>(model);
                response.Data = await _Domain.InsertAsync(resp);

                if (response.Data == "Success")
                {
                    response.IsSuccess = true;
                    response.Message   = "Se ha registrado el User exitosamente.";
                }
                else
                {
                    response.IsSuccess = false;
                    response.Message   = "Ha ocurrido un error inesperado, por favor intente nuevamente";
                    _logger.LogWarning("Ha ocurrido un error inesperado registrando el usuario " + model.Username + ", (" + response.Data + ")");
                }
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
                _logger.LogError(ex.Message);
            }

            return(response);
        }
Пример #2
0
        public async Task <Response <UserAddModel> > InsertAsync(UserAddModel userModel)
        {
            var response = new Response <UserAddModel>();

            try
            {
                var userToInst = _mapper.Map <User>(userModel);
                var user       = await _userModelDomain.InsertAsync(userToInst);

                response.Data = _mapper.Map <UserAddModel>(user);
                if (response.Data != null)
                {
                    response.IsSuccess = true;
                    response.Message   = "Registro Exitoso!!!";
                }
            }
            catch (Exception e)
            {
                response.Message = e.Message;
            }
            return(response);
        }