Exemple #1
0
 public ActionResult Create(Customer customer)
 {
     try
     {
         using (var service = new ServiceModeloNegocio.ServiceClient())
         {
             customer.Estado = Estado.ACTIVO; //un cliente deberia estar activo cuando se crea...
             service.CreateCustomer(customer);
             return(RedirectToAction("Index"));
         }
     }
     catch
     {
         return(View("Index"));
     }
 }
Exemple #2
0
        public HttpResponseMessage Post(Customer customer

                                        /*
                                         * string Customer_name
                                         * , string Customer_address
                                         * , TipoDocumento tipoDocumento
                                         * , string document_nro
                                         * , string Email
                                         * , string Phone
                                         */
                                        )
        {
            using (var service = new ServiceModeloNegocio.ServiceClient())
            {
                try
                {   /*
                     * var customer = new Customer
                     * {
                     *  Customer_name = Customer_name,
                     *  Address = Customer_address,
                     *  Document_type = tipoDocumento,
                     *  Document_nro = document_nro,
                     *  Email = Email,
                     *  Phone = Phone,
                     *  Estado = Estado.ACTIVO
                     * };
                     */
                    customer.Estado = Estado.ACTIVO;

                    service.CreateCustomer(customer);
                    return(Request.CreateResponse <Customer>(HttpStatusCode.Created, customer));
                }catch (Exception e)
                {
                    return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message));
                }
            }
        }