Beispiel #1
0
 // PUT api/cliente/5
 public bool Put(int id, [FromBody] ClienteInputType clienteInputType)
 {
     if (id > 0)
     {
         return(_clienteServices.ActualizarCliente(id, clienteInputType));
     }
     return(false);
 }
Beispiel #2
0
        // POST api/cliente
        public HttpResponseMessage Post([FromBody] ClienteInputType clienteInputType)
        {
            try
            {
                var guardarCliente = _clienteServices.GuardarCliente(clienteInputType);

                return(Request.CreateResponse(HttpStatusCode.OK, guardarCliente));
            }
            catch (ApplicationException ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
Beispiel #3
0
 /// <summary>
 /// Guardar un cliente
 /// </summary>
 /// <param name="clienteInputType"></param>
 /// <returns></returns>
 public int GuardarCliente(ClienteInputType clienteInputType)
 {
     using (var scope = new TransactionScope())
     {
         var cliente = new CLIENTE
         {
             CORREO_ELECTRONICO = clienteInputType.CorreoElectronico,
             NOMBRE             = clienteInputType.Nombre,
             PRIMER_APELLIDO    = clienteInputType.PrimerApellido
         };
         _unitOfWork.ClienteRepository.Insert(cliente);
         _unitOfWork.Save();
         scope.Complete();
         return(cliente.CLIENTE_ID);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Actualiza producto
        /// </summary>
        /// <param name="clienteId"></param>
        /// <param name="clienteInputType"></param>
        /// <returns></returns>
        public bool ActualizarCliente(int clienteId, ClienteInputType clienteInputType)
        {
            var success = false;

            if (clienteInputType != null)
            {
                using (var scope = new TransactionScope())
                {
                    var cliente = _unitOfWork.ClienteRepository.GetById(clienteId);
                    if (cliente != null)
                    {
                        cliente.CORREO_ELECTRONICO = clienteInputType.CorreoElectronico;
                        cliente.NOMBRE             = clienteInputType.Nombre;
                        cliente.PRIMER_APELLIDO    = clienteInputType.PrimerApellido;

                        _unitOfWork.ClienteRepository.Update(cliente);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }