Exemplo n.º 1
0
        public ActionResult DefinePlan(DefineNewPlan command, FormCollection formCollection)
        {
            command.PlanId    = Guid.NewGuid().ToString();
            command.CompanyId = MvcApplication.CompanyId;

            try
            {
                var 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["PlanTypes"] = new SelectList(GetPlanTypes());
                    return(View(command));
                }

                return(RedirectToAction("Index"));
            }
            catch (TimeoutException toe)
            {
                ModelState.AddModelError("TimeOutError", toe.Message);
                ViewData["PlanTypes"] = new SelectList(GetPlanTypes());
                return(View(command));
            }
            catch
            {
                return(View());
            }
        }
Exemplo n.º 2
0
 public void DefineNewPlan(DefineNewPlan command)
 {
     ApplyEvent(new NewPlanDefinedEvent
     {
         PlanId      = command.PlanId,
         CompanyId   = command.CompanyId,
         Description = command.Description,
         Name        = command.Name,
         PlanType    = command.PlanType,
         Version     = 0,
     }
                ,
                @event => _planState.Apply(@event));
 }