public static DTOCerveza ObtenerCerveza(ref HttpStatusCode estado, ref string mensaje, int id) { DTOCerveza Cerveza = new DTOCerveza(); try { var parametros = new Dictionary <string, object>(); parametros.Add("Id", id); var Cervezas = Base.baseFactory.Obtener().ObtenerLista <DTOCerveza>("PA_ObtenerCervezas", parametros); if (Cervezas.Count() == 0) { estado = HttpStatusCode.NotFound; mensaje = "no se encontro la cerveza"; return(null); } Cerveza = Cervezas[0]; estado = HttpStatusCode.Found; } catch (SqlException sqlex) { MetodosComunes.SQLCatch(sqlex.Number); //throw; } catch (Exception e) { //estado = HttpStatusCode.InternalServerError; throw; } return(Cerveza); }
public static void CrearCerveza(ref HttpStatusCode estado, DTOCerveza cerveza) { try { var parametros = new Dictionary <string, object>(); parametros.Add("Marca", cerveza.Marca); parametros.Add("Alcohol", cerveza.Alcohol); parametros.Add("TipoId", cerveza.TipoId); parametros.Add("PaisId", cerveza.PaisId); Base.baseFactory.Insertar().Insert("PA_NuevaCerveza", parametros); estado = HttpStatusCode.Created; } catch (SqlException sqlex) { estado = MetodosComunes.SQLCatch(sqlex.Number); throw; } catch (Exception e) { estado = HttpStatusCode.InternalServerError; throw; } }
public HttpResponseMessage Obtener(int id) { string mensaje = string.Empty; HttpStatusCode estado = default(HttpStatusCode); try { DTOCerveza token = CervezaLogica.ObtenerCerveza(ref estado, ref mensaje, id); return(HTTPResponseHelp.CrearResponse <DTORespuesta <DTOCerveza> >(this, new DTORespuesta <DTOCerveza>() { Mensaje = mensaje, Entidad = token }, estado)); } catch { return(HTTPResponseHelp.CrearResponse <DTORespuesta <String> >(this, new DTORespuesta <string>() { Mensaje = "Error" }, HttpStatusCode.InternalServerError)); } }