public async Task<IHttpActionResult> PostLineaSubteModel(LineaSubteModel lineaSubteModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.LineaSubteModels.Add(lineaSubteModel);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (LineaSubteModelExists(lineaSubteModel.Id))
                {
                    return Conflict();
                }
                else
                {
                    throw;
                }
            }

            return CreatedAtRoute("DefaultApi", new { id = lineaSubteModel.Id }, lineaSubteModel);
        }
        public async Task<IHttpActionResult> PutLineaSubteModel(string id, LineaSubteModel lineaSubteModel)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != lineaSubteModel.Id)
            {
                return BadRequest();
            }

            db.Entry(lineaSubteModel).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!LineaSubteModelExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
Exemplo n.º 3
0
    public static List<LineaSubteModel> Find(string file)
    {
      List<LineaSubteModel> list = new List<LineaSubteModel>();

      HtmlDocument doc = new HtmlDocument();
      doc.LoadHtml(file);
      var nodes = doc.DocumentNode.Descendants("span").Where(div => div.Id.Contains("status-line"));
      foreach (var node in nodes)
      {
        LineaSubteModel i = new LineaSubteModel();
        i.Id = node.Id.Substring(node.Id.Length - 1, 1);
        i.Name= node.InnerText;
        list.Add(i);
      }
      return list;
    }