Beispiel #1
0
        public IActionResult Create([FromBody] SellerViewModel seller)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Seller _newSeller = Mapper.Map <SellerViewModel, Seller>(seller);

            _newSeller.CreateDate = DateTime.Now;

            _sellerRepository.Add(_newSeller);
            _sellerRepository.Commit();

            seller = Mapper.Map <Seller, SellerViewModel>(_newSeller);

            CreatedAtRouteResult result = CreatedAtRoute("GetSeller", new { controller = "Seller", id = seller.Id }, seller);

            return(result);
        }