public async Task <JsonResult> RegistrarListaCategoriaProducto(ent.ListaCategoriaProductoTransaccion entidad) { bool status = false; data.Categoria cate = new data.Categoria() { Nombre_Categoria = entidad.Nombre_Categoria }; List <data.Producto> prod = new List <data.Producto>(); foreach (var item in entidad.DetalleProducto) { prod.Add(new data.Producto() { Nombre_Producto = item.Nombre_Producto }); } try { await new app.TransaccionCategoriaProducto().RegistrarListaTransaccionCategoriaProducto(cate, prod); status = true; } catch { status = false; } return(new JsonResult { Data = new { status = status } }); }
public async Task Eliminar(ent.Categoria entidad) { map.Mapear.CrearMapaCategoria(); var _entidad = Mapper.Map <ent.Categoria, data.Categoria>(entidad); await new dom.Categoria().Eliminar(_entidad); }
public async Task RegistrarTransaccionCategoriaProducto(ent.Categoria cate, ent.Producto prod) { map.Mapear.CrearMapaCategoria(); data.Categoria _categoria = Mapper.Map <ent.Categoria, data.Categoria>(cate); map.Mapear.CrearMapaProducto(); data.Producto _producto = Mapper.Map <ent.Producto, data.Producto>(prod); await new dom.TransaccionCategoriaProducto().RegistrarTransaccionCategoriaProducto(_categoria, _producto); }
public async Task <ActionResult> DetalleCategorias(int id) { ViewBag.Message = "Eliminar categoria."; data.Categoria listar = await new app.Categoria().TraerUnoPorId(id); var config = new MapperConfiguration(cfg => cfg.CreateMap <data.Categoria, ent.Categoria>()); var mapper = config.CreateMapper(); ent.Categoria cate = mapper.Map <data.Categoria, ent.Categoria>(listar); return(View(cate)); }
public async Task <ActionResult> DetalleCategoriaServicio(int id) { var httpClient = new HttpClient(); var json = await httpClient.GetStringAsync("http://localhost:8082/api/Categoria/" + id); data.Categoria cate = JsonConvert.DeserializeObject <data.Categoria>(json); var config = new MapperConfiguration(cfg => cfg.CreateMap <data.Categoria, ent.Categoria>()); var mapper = config.CreateMapper(); ent.Categoria catelist = mapper.Map <data.Categoria, ent.Categoria>(cate); return(View(catelist)); }
public async Task <HttpResponseMessage> PutCategoria(ent.Categoria categoria) { try { await new app.Categoria().Modificar(categoria); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, categoria); return(response); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
// POST: api/Categoria public async Task <HttpResponseMessage> PostCategoria(ent.Categoria categoria) { try { await new app.Categoria().Registrar(categoria); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, categoria); response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = categoria.ID_Categoria })); return(response); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public async Task <ActionResult> RegistrarCategoriaProducto(ent.CategoriaTransaccion entidad) { data.Categoria cate = new data.Categoria() { Nombre_Categoria = entidad.categoria.Nombre_Categoria }; data.Producto prod = new data.Producto() { Nombre_Producto = entidad.producto.Nombre_Producto }; await new app.TransaccionCategoriaProducto().RegistrarTransaccionCategoriaProducto(cate, prod); return(View()); }
// DELETE: api/Categoria/5 public async Task <HttpResponseMessage> Delete(int id) { try { ent.Categoria cate = await new app.Categoria().TraerUnoPorId(id); await new app.Categoria().Eliminar(cate); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, id); response.Headers.Add("Access-Control-Allow-Origin", "*"); return(response); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message)); } }
public async Task <HttpResponseMessage> PostListTransaccionCategoriaProducto(mod.ListaCategoriaProducto cateprod) { try { ent.Categoria cate = cateprod.categoria; List <ent.Producto> prod = cateprod.producto; await new app.TransaccionCategoriaProducto().RegistrarListaTransaccionCategoriaProducto(cate, prod); HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, cate.Nombre_Categoria); return(response); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex)); } }
public async Task <ActionResult> EliminarCategorias(ent.Categoria entidad) { data.Categoria listar = await new app.Categoria().TraerUnoPorId(entidad.ID_Categoria); await new app.Categoria().Eliminar(listar); return(RedirectToAction("ListarCategorias")); }