public async Task <IActionResult> PutProductMechanism([FromRoute] int id, [FromBody] ProductMechanism productMechanism) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != productMechanism.Id) { return(BadRequest()); } _context.Entry(productMechanism).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductMechanismExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ProductMechanismViewModel(MerkatoDbContext context, ProductMechanism product) : this(context) { this.Id = product.Id; this.MechanismId = product.MechanismId; this.ProductId = product.ProductId; this.ProductOrder = product.ProductOrder; this.Quantity = product.Quantity; }
public ProductMechanism GetModel() { ProductMechanism a = new ProductMechanism(); a.Id = this.Id; a.MechanismId = this.MechanismId; a.ProductId = this.ProductId; a.ProductOrder = this.ProductOrder; a.Quantity = this.Quantity; return(a); }
public async Task <IActionResult> PostProductMechanism([FromBody] ProductMechanism productMechanism) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.ProductMechanism.Add(productMechanism); await _context.SaveChangesAsync(); return(CreatedAtAction("GetProductMechanism", new { id = productMechanism.Id }, productMechanism)); }