public static void InitializeData() { // Console.WriteLine("Init"); foreach (ItemEN i in itemCEN.BuscarTodos(0, -1)) { if (i.EsValido == EstadoEnum.enProceso) { changed_ids.Add(i.Id); itemCEN.Modificar(i.Id, i.Nombre, i.Descripcion, i.Imagen, EstadoEnum.descartado, 10); // Console.WriteLine("Mod " + i.Id); } } for (int i = 0; i < new_elements; i++) { int id = itemCEN.Crear("Item Test", "Item Test", "TEST IMG", -1, -1); item = itemCEN.BuscarPorId(id); itemCEN.Modificar(id, item.Nombre, item.Descripcion, item.Imagen, EstadoEnum.enProceso, 10); ids.Add(id); // Console.WriteLine("Added " + id); } }
public HttpResponseMessage BuscarTodos() { // CAD, CEN, EN, returnValue ItemRESTCAD itemRESTCAD = null; ItemCEN itemCEN = null; List <ItemEN> itemEN = null; List <ItemDTOA> returnValue = null; try { SessionInitializeWithoutTransaction(); string token = ""; if (Request.Headers.Authorization != null) { token = Request.Headers.Authorization.ToString(); } int id = new UsuarioCEN().CheckToken(token); itemRESTCAD = new ItemRESTCAD(session); itemCEN = new ItemCEN(itemRESTCAD); // Data // TODO: paginación itemEN = itemCEN.BuscarTodos(0, -1).ToList(); // Convert return if (itemEN != null) { returnValue = new List <ItemDTOA>(); foreach (ItemEN entry in itemEN) { returnValue.Add(ItemAssembler.Convert(entry, session)); } } } catch (Exception e) { if (e.GetType() == typeof(HttpResponseException)) { throw e; } else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto")) { throw new HttpResponseException(HttpStatusCode.Forbidden); } else if (e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(ReciclaUAGenNHibernate.Exceptions.DataLayerException)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } else { throw new HttpResponseException(HttpStatusCode.InternalServerError); } } finally { SessionClose(); } // Return 204 - Empty if (returnValue == null || returnValue.Count == 0) { return(this.Request.CreateResponse(HttpStatusCode.NoContent)); } // Return 200 - OK else { return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue)); } }
public void WhenObtengoLosItems() { items = itemCEN.BuscarTodos(0, -1); }