public async Task <IActionResult> PutMerchendise(int?id, Merchendise merchendise) { if (id != merchendise.Id) { return(BadRequest()); } _context.Entry(merchendise).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MerchendiseExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <Merchendise> > PostMerchendise(Merchendise merchendise) { _context.Merchendise.Add(merchendise); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMerchendise", new { id = merchendise.Id }, merchendise)); }
public int Create(Merchendise item) { this.items.Add(item); this.items.Save(); return(item.Id); }
public void Update(int id, Merchendise item) { var entityToUpdate = this.items.GetById(id); entityToUpdate.Title = item.Title; entityToUpdate.Description = item.Description; entityToUpdate.PriceUSD = item.PriceUSD; entityToUpdate.Availability = item.Availability; entityToUpdate.Images = item.Images; this.items.Save(); }
public MerchendiseDao EntityToDao(Merchendise entity) { MerchendiseDao dao = new MerchendiseDao { Id = entity.Id, Description = entity.Description, Name = entity.Name, Price = entity.Price, Type = entity.Type, RefLabelId = converter.EntityToDao(entity.RefLabelId), HasStock = entity.HasStock }; return(dao); }
public Merchendise DaoToEntity(MerchendiseDao dao) { Merchendise entity = new Merchendise { Id = dao.Id, Description = dao.Description, Name = dao.Name, Price = dao.Price, Type = dao.Type, RefLabelId = converter.DaoToEntity(dao.RefLabelId), HasStock = dao.HasStock }; return(entity); }
public int Create(string title, string description, string sellerId, decimal price, int availability) { var newEntity = new Merchendise() { Title = title, Description = description, SellerId = sellerId, PriceUSD = price, Availability = availability }; this.items.Add(newEntity); this.items.Save(); return(newEntity.Id); }
public void Add(MerchendiseDao dao) { Merchendise entity = _converter.DaoToEntity(dao); _repository.Add(entity); }