public HttpResponseMessage Guardar([FromBody] M_Carrito c) { try { if (ValidarAutorizacion()) { var x = CarritoRepositorio.Guardar(c); if (x == false) { return(OkResponse("Hubo un error al recuperar el registro")); } else { return(OkResponse(x)); } } else { return(OkResponse("No tiene acceso")); } } catch (Exception) { return(ErrorResponse("Ha ocurrido un error")); throw; } }
public HttpResponseMessage Actualizar([FromBody] M_Carrito a) { try { if (ValidarAutorizacion()) { var x = CarritoRepositorio.Actualizar(a); if (x == false) { return(OkResponse("Hubo un error al tratar de actualizar")); } else { return(OkResponse(x)); } } else { return(OkResponse("No tiene acceso")); } } catch (Exception) { return(ErrorResponse("Ha ocurrido un error")); throw; } }
public static bool Actualizar(M_Carrito c) { var result = false; try { var db = new EcomerceEntities(); var x = db.Carrito.SingleOrDefault(k => k.ID == c.ID); if (x != null) { x.IDCliente = c.IDCliente; x.IDProducto = c.IDProducto; db.SaveChanges(); result = true; return(result); } else { return(result); } } catch (Exception ex) { return(false); throw; } }
public static Carrito ConvertToDBTable(M_Carrito c) { return(new Carrito { ID = c.ID, IDCliente = c.IDCliente, IDProducto = c.IDProducto, }); }
public static bool Guardar(M_Carrito c) { try { var db = new EcomerceEntities(); var x = ConvertToDBTable(c); db.Carrito.Add(x); db.SaveChanges(); return(true); } catch (Exception ex) { return(false); throw; } }