Ejemplo n.º 1
0
        public async Task <IActionResult> AddBox([FromBody] BoxCreationData boxCreationData)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var box = await _boxService.AddBox(User.GetId(), boxCreationData);

            return(CreatedAtAction(nameof(GetBox), new { boxId = box.Id }, box));
        }
Ejemplo n.º 2
0
        public ActionResult Create(BoxDTO model)
        {
            if (ModelState.IsValid)
            {
                // boxtype name i verilip ox type ID si dmnen servis yazılacak
                // var boxTypeID = _bts.GetBoxTypes().Result.Where(x => x.Type == model.).Select(x => x.ID).FirstOrDefault();
                BoxDTO boxDTO = new BoxDTO
                {
                    BoxName      = model.BoxName,
                    BoxTypeID    = model.BoxTypeID,
                    Description  = model.Description,
                    ImageUrl     = model.ImageUrl,
                    Price        = model.Price,
                    UnitsInStock = model.UnitsInStock
                };
                var result = _bs.AddBox(boxDTO);

                return(RedirectToAction("Index", "AdminBox"));
            }
            GetViewBagData();
            return(View());
        }