Exemplo n.º 1
0
        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());
        }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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));
        }