public async Task <IActionResult> PutTechline([FromRoute] int id, [FromBody] Techline techline)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            _context.Entry(techline).State = EntityState.Modified;

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

            return(NoContent());
        }
        public async Task <IActionResult> PostTechline([FromBody] Techline techline)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.Techlines.Add(techline);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTechline", new { id = techline.Id }, techline));
        }
Example #3
0
 public ActionResult Save(Techline techline)
 {
     _context.Techlines.Add(techline);
     _context.SaveChanges();
     return(RedirectToAction("Index", "Home"));
 }