Exemplo n.º 1
0
        public async Task <Response <string> > InsertAsync(CustomerDTO model)
        {
            var response = new Response <string>();

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

                if (response.Data == "Success")
                {
                    response.IsSuccess = true;
                    response.Message   = "Se ha registrado el Customer exitosamente.";
                }
                else
                {
                    response.IsSuccess = false;
                    response.Message   = "Ha ocurrido un error inesperado, por favor intente nuevamente";
                }
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
Exemplo n.º 2
0
        public async Task <Response <bool> > InsertAsync(CustomerDTO customerDTO)
        {
            var response = new Response <bool>();

            try
            {
                var customer = mapper.Map <Customer>(customerDTO);
                response.Data = await customerDomain.InsertAsync(customer);

                if (response.Data)
                {
                    response.IsSuccess = true;
                    response.Message   = "Registro exitoso";
                }
            }
            catch (Exception e)
            {
                response.Message = e.Message;
            }
            return(response);
        }