示例#1
0
        public HttpResponseMessage Borrar(int p_item_oid)
        {
            // CAD, CEN
            ItemRESTCAD itemRESTCAD = null;
            ItemCEN     itemCEN     = null;

            try
            {
                SessionInitializeTransaction();
                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);

                itemCEN.Borrar(p_item_oid);
                SessionCommit();
            }

            catch (Exception e)
            {
                SessionRollBack();

                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 - No Content
            return(this.Request.CreateResponse(HttpStatusCode.NoContent));
        }
 public static void CleanData()
 {
     // Console.WriteLine("Destroy");
     foreach (int id in changed_ids)
     {
         ItemEN i = itemCEN.BuscarPorId(id);
         itemCEN.Modificar(id, i.Nombre, i.Descripcion, i.Imagen, EstadoEnum.enProceso, 10);
         // Console.WriteLine("Recover " + id);
     }
     foreach (int id in ids)
     {
         itemCEN.Borrar(id);
         // Console.WriteLine("Deleted " + id);
     }
 }
 public static void CleanData()
 {
     itemCEN.Borrar(itemId);
     new MaterialCEN().Borrar(materialId);
 }
示例#4
0
 public static void CleanData()
 {
     itemCEN.Borrar(id);
 }
 public static void CleanData()
 {
     new MaterialCEN().Borrar(idMaterial);
     itemCEN.Borrar(itemId1);
     itemCEN.Borrar(itemId2);
 }
 public void WhenEliminoElItem()
 {
     itemCEN.Borrar(itemId);
 }