Example #1
0
 public void Update(BoxItemsModel boxItem)
 {
     BoxItemId    = boxItem.BoxItemId;
     BoxId        = boxItem.BoxId;
     InventoryId  = boxItem.InventoryId;
     BoxItemPrice = boxItem.BoxItemPrice;
 }
Example #2
0
        public IHttpActionResult PostBoxItem(BoxItemsModel boxItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dbBoxItem = new BoxItem();

            dbBoxItem.Update(boxItem);

            _boxItemRepository.Add(dbBoxItem);
            _unitOfWork.Commit();

            boxItem.BoxItemId = dbBoxItem.BoxItemId;

            return(CreatedAtRoute("DefaultApi", new { id = boxItem.BoxItemId }, boxItem));
        }
Example #3
0
        public IHttpActionResult PutBoxItem(int id, BoxItemsModel boxItem)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            BoxItem dbBoxItem = _boxItemRepository.GetFirstOrDefault(b => b.Box.PawzeUser.UserName == User.Identity.Name && b.BoxItemId == id);

            if (id != boxItem.BoxItemId)
            {
                return(BadRequest());
            }

            dbBoxItem.Update(boxItem);

            _boxItemRepository.Update(dbBoxItem);

            try
            {
                _unitOfWork.Commit();
            }
            catch (Exception)
            {
                if (!BoxItemExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Example #4
0
 public BoxItem(BoxItemsModel boxItem)
 {
     this.Update(boxItem);
 }