public void DefineNewBenefit(DefineNewBenefit command)
 {
     ApplyEvent(new NewBenefitDefinedEvent
         {
             BenefitId = command.BenefitId,
             BenefitDescription = command.BenefitDescription,
             BenefitType = command.BenefitType,
             HasMaxElectionAmount = command.HasMaxAmount,
             MaxElectionAmount = command.MaxBenefitAmount,
             PlanId = command.PlanId,
             CompanyId = command.CompanyId,
         }, 
         @event => _state.Apply(@event));
 }
        public ActionResult Create(DefineNewBenefit command, FormCollection collection)
        {
            if (ModelState.IsValid == false)
            {
                return View();
            }

            try
            {
                //push our DefineNewBenefit command message on to the bus.
                command.BenefitId = Guid.NewGuid().ToString();
                command.CompanyId = MvcApplication.CompanyId;
                CommandResponse response = _commandSender.Send(command);

                if (response.CommandStatus == CommandStatusEnum.Failed)
                {
                    //set the error message in the ViewData and return to the view
                    ModelState.AddModelError("ResponseError", response.Message);
                    ViewData["PlansOffered"] = new SelectList(GetPlansOffered(), "Id", "Name");
                    ViewData["BenefitType"] = new SelectList(GetBenefitTypes());
                    return View();
                }

                return RedirectToAction("List");
            }
            catch (TimeoutException toe)
            {
                ModelState.AddModelError("TimeOutError", toe.Message);
                ViewData["PlansOffered"] = new SelectList(GetPlansOffered(), "Id", "Name");
                ViewData["BenefitType"] = new SelectList(GetBenefitTypes());
                return View();
            }
            catch
            {
                return View();
            }
        }