示例#1
0
        public async Task <ActionResult> Create([FromBody] CreateSellerContactDTO sellerContactDTO)
        {
            SellerContact sellerContact = _mapper.Map <SellerContact>(sellerContactDTO);
            await _sellerContactRepository.CreateAsync(sellerContact);

            return(CreatedAtRoute("GetSellerContactById", new { sellerContact.Id }, sellerContact));
        }
示例#2
0
        public async Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
        {
            ISellerRepository      sellerRepository = (ISellerRepository)context.HttpContext.RequestServices.GetService(typeof(ISellerRepository));
            CreateSellerContactDTO sellerContactDTO = (CreateSellerContactDTO)context.ActionArguments["sellerContactDTO"];

            if (!await sellerRepository.ExistsAsync(sellerContactDTO.SellerId))
            {
                context.ModelState.AddModelError("SellerId", "The given seller id does not correspond to an existing seller");
            }

            await next();
        }