public IActionResult Create([FromBody] CampaignInputModel inputModel)
        {
            if (inputModel == null)
            {
                return(BadRequest());
            }


            var campaign = inputModel.ToEntity();

            if (!_productStore.Exists(campaign.ProductId))
            {
                ModelState.AddModelError("Product", $"Product '{campaign.ProductId}' does not exists.");
                return(BadRequest(ModelState));
            }

            campaign = _service.Create(campaign);
            campaign = _service.GetById(campaign.Id);
            if (null == campaign)
            {
                return(NoContent());
            }

            var outputModel = CampaignOutputModel.FromEntity(campaign);

            return(CreatedAtRoute("ViewCampaign",
                                  new { id = outputModel.Id }, outputModel));
        }
        // GET: Campaigns/Details/5
        public IActionResult Details(int?id)
        {
            Campaign campaign = FetchOrDefault(id);

            if (null == campaign)
            {
                return(NotFound());
            }

            return(View(CampaignOutputModel.FromEntity(campaign)));
        }
        public ActionResult <CampaignOutputModel> Get(int id)
        {
            Campaign campaign = _service.GetById(id);

            if (null == campaign)
            {
                return(NoContent());
            }

            return(CampaignOutputModel.FromEntity(campaign));
        }
        public IActionResult Create([FromForm] CampaignInputModel inputModel)
        {
            if (!ModelState.IsValid)
            {
                ViewData["ProductId"] = new SelectList(_productStore.List(), "Id", "Name");
                return(View(inputModel));
            }

            var campaign = inputModel.ToEntity();

            if (!_productStore.Exists(campaign.ProductId))
            {
                ModelState.AddModelError("Product", $"Product '{campaign.ProductId}' does not exists.");
                return(BadRequest(ModelState));
            }

            campaign = _service.Create(campaign);

            var outputModel = CampaignOutputModel.FromEntity(campaign);

            return(RedirectToAction(nameof(Index)));
        }