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));
        }
예제 #3
0
        public int Create(Merchendise item)
        {
            this.items.Add(item);

            this.items.Save();

            return(item.Id);
        }
예제 #4
0
        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();
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }