Exemple #1
0
        public IHttpActionResult PostBox(BoxesModel box)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var dbBox = new Box();

            dbBox.PawzeUser = _userRepository.GetFirstOrDefault(u => u.UserName == User.Identity.Name);

            dbBox.Update(box);

            foreach (var boxItem in dbBox.BoxItems)
            {
                boxItem.BoxItemPrice = _configRepository.GetAll().First().CurrentBoxItemPrice;
            }

            _boxRepository.Add(dbBox);

            _unitOfWork.Commit();

            box.BoxId = dbBox.BoxId;

            return(CreatedAtRoute("DefaultApi", new { id = box.BoxId }, box));
        }