// GET: Order/Edit/5 public ActionResult Edit(int id) { //TODO: la plantilla de editar y crear son iguales podria refactorizarse... using (var service = new ServiceModeloNegocio.ServiceClient()) { ViewBag.ProductosDisponibles = service.GetAllProductsDisponibles(); ViewBag.CustomersList = service.GetListCustomersByEstado(Estado.ACTIVO); /* * Creo un ListItem solo con numeros para mostrar en un elemento ListBox en la plantilla de crear orden */ var cantidad = new List <ListItem>(); const int cantidad_maxima_productos = 5; // Es la cantidad maxima de productos que puede seleccionar un usuario for (int count = 0; count <= cantidad_maxima_productos; count++) { cantidad.Add(new ListItem { Text = count.ToString(), Value = count.ToString() }); } ViewBag.CantidadProductos = cantidad; var order = service.GetOrderById(id); ViewBag.OrdenAeditar = order; return(View()); } }
public Product Get(int id) { using (var service = new ServiceModeloNegocio.ServiceClient()) { var product = service.GetProductById(id); return(product); } }
public HttpResponseMessage Put(Product product) { using (var service = new ServiceModeloNegocio.ServiceClient()) { service.EditProduct(product); return(Request.CreateResponse <Product>(HttpStatusCode.OK, product)); } }
public HttpResponseMessage Put([FromBody] Customer customer) { using (var service = new ServiceModeloNegocio.ServiceClient()) { service.EditCustomer(customer); return(Request.CreateResponse <Customer>(HttpStatusCode.OK, customer)); } }
public IList <Customer> Get() { using (var service = new ServiceModeloNegocio.ServiceClient()) { var customers = service.GetAllCustomers(); return(customers); } }
public Customer Get(int id) { using (var service = new ServiceModeloNegocio.ServiceClient()) { var customer = service.GetCustomerById(id); return(customer); } }
// GET: Order public ActionResult Index() { using (var service = new ServiceModeloNegocio.ServiceClient()) { var orders = service.GetAllOrders(); return(View(orders)); } }
// GET: Order/Details/5 public ActionResult Details(int id) { using (var service = new ServiceModeloNegocio.ServiceClient()) { var order = service.GetOrderById(id); return(View(order)); } }
public Order Get(int id) { using (var service = new ServiceModeloNegocio.ServiceClient()) { var order = service.GetOrderById(id); return(order); } }
public IList <Order> Get() { using (var service = new ServiceModeloNegocio.ServiceClient()) { var orders = service.GetAllOrders(); return(orders); } }
// GET: Product public ActionResult Index() { using (var service = new ServiceModeloNegocio.ServiceClient()) { var products = service.GetAllProducts(); return(View(products)); } }
// GET: Product/Delete/5 public ActionResult Delete(int id) { using (var service = new ServiceModeloNegocio.ServiceClient()) { var product = service.GetProductById(id); return(View(product)); } }
public HttpResponseMessage Put(Order order) { using (var service = new ServiceModeloNegocio.ServiceClient()) { service.EditOrder(order); return(Request.CreateResponse <Order>(HttpStatusCode.OK, order)); } }
public IList <Product> Get() { using (var service = new ServiceModeloNegocio.ServiceClient()) { var products = service.GetAllProducts(); return(products); } }
// GET: Customer/Delete/5 public ActionResult Delete(int id) { using (var service = new ServiceModeloNegocio.ServiceClient()) { var customer = service.GetCustomerById(id); return(View(customer)); } }
public HttpResponseMessage Delete(int id) { using (var service = new ServiceModeloNegocio.ServiceClient()) { var order = service.GetOrderById(id); service.DeleteOrder(order); return(Request.CreateResponse <Order>(HttpStatusCode.Gone, order)); } }
public HttpResponseMessage Delete(int id) { using (var service = new ServiceModeloNegocio.ServiceClient()) { var customer = service.GetCustomerById(id); service.DeleteCustomer(customer); return(Request.CreateResponse(HttpStatusCode.Gone)); } }
public HttpResponseMessage Post(Order order) { using (var service = new ServiceModeloNegocio.ServiceClient()) { order.Estado = Estado.ACTIVO; //TODO: ahora q lo pienso esto podria ponerlo en el service data... service.CreateOrder(order); return(Request.CreateResponse <Order>(HttpStatusCode.Created, order)); } }
public HttpResponseMessage Delete(int id) { using (var service = new ServiceModeloNegocio.ServiceClient()) { var product = service.GetProductById(id); service.DeleteProduct(product); return(Request.CreateResponse <Product>(HttpStatusCode.Gone, product)); } }
// GET: Product/Edit/5 public ActionResult Edit(int id) { using (var service = new ServiceModeloNegocio.ServiceClient()) { var product = service.GetProductById(id); ViewBag.Estados = GetEstadosDisponibles(); return(View(product)); } }
// GET: Customer/Edit/5 public ActionResult Edit(int id) { using (var service = new ServiceModeloNegocio.ServiceClient()) { var customer = service.GetCustomerById(id); ViewBag.EstadosCustomer = GetEstadosCustomer(); ViewBag.TipoDocumentos = GetTipoDocumentos(); ViewBag.EstadoDelCustomer = customer.Estado; ViewBag.TipoDocumentoCustomer = customer.Document_type; return(View(customer)); } }
public ActionResult Edit(Product product) { try { using (var service = new ServiceModeloNegocio.ServiceClient()) { service.EditProduct(product); return(RedirectToAction("Index")); } } catch { return(View()); } }
public ActionResult Edit(Customer Customer) { try { using (var service = new ServiceModeloNegocio.ServiceClient()) { service.EditCustomer(Customer); return(RedirectToAction("Index")); } } catch { return(View("Index")); } }
public ActionResult Create(Product product) { try { using (var service = new ServiceModeloNegocio.ServiceClient()) { service.CreateProduct(product); return(RedirectToAction("Index")); } } catch { //hacer algo si sale mal... return(View("index")); } }
public ActionResult Delete(int id, FormCollection collection) { try { using (var service = new ServiceModeloNegocio.ServiceClient()) { var product = service.GetProductById(id); service.DeleteProduct(product); return(RedirectToAction("Index")); } } catch { return(View("Index")); } }
public ActionResult Edit(Order order) { order.Details = order.Details.Where(o => o.Quantity != 0).ToArray(); // recorro el array y elimino los registros con quantiy = 0 try { using (var service = new ServiceModeloNegocio.ServiceClient()) { service.EditOrder(order); return(RedirectToAction("Index")); } } catch { return(View()); } }
public ActionResult Delete(int id, FormCollection collection) { try { using (var service = new ServiceModeloNegocio.ServiceClient()) { var customer = service.GetCustomerById(id); service.DeleteCustomer(customer); return(RedirectToAction("Index")); } } catch { return(View("Index")); } }
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")); } }
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)); } } }