public static bool Actualizar(M_Categorias c) { var result = false; try { var db = new EcomerceEntities(); var x = db.Categorias.SingleOrDefault(k => k.ID == c.ID); if (x != null) { x.Nombre = c.Nombre; db.SaveChanges(); result = true; return(result); } else { return(result); } } catch (Exception ex) { return(false); throw; } }
public HttpResponseMessage Guardar([FromBody] M_Categorias c) { try { if (ValidarAutorizacion()) { var x = CategoriasRepositorio.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_Categorias a) { try { if (ValidarAutorizacion()) { var x = CategoriasRepositorio.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 Categorias ConvertToDBTable(M_Categorias c) { return(new Categorias { ID = c.ID, Nombre = c.Nombre, }); }
public static bool Guardar(M_Categorias c) { try { var db = new EcomerceEntities(); var x = ConvertToDBTable(c); db.Categorias.Add(x); db.SaveChanges(); return(true); } catch (Exception ex) { return(false); throw; } }