public void ShouldRegisterPlanWhenPlanIsValid() { var commandPlan = new CreatePlanCommand(); commandPlan.Id = Guid.NewGuid(); commandPlan.NameField = "Plano de Aposentadoria AlphaPrev"; commandPlan.Abreviation = "AlphaPrev"; commandPlan.Description = "Plano Criado para os empregados da empresa Alpha"; commandPlan.Active = true; commandPlan.Cnpb = 4598483201; commandPlan.AmountAnnualBenefits = 12; commandPlan.AmountAnnualContributions = 12; commandPlan.CountEmployeeContribution = false; commandPlan.Effecive = DateTime.Now; commandPlan.Inclusion = DateTime.Now; commandPlan.RegulationNew = true; commandPlan.ReservationSpecialVirtual = false; commandPlan.SalaryAdjustmentMonth = 2; commandPlan.TypePlan = Domain.Enums.EPlanType.Pension; commandPlan.MonthlyProcessing = true; var handler = new PlanHandler(new FakePlanRepository(), new FakeEmailService()); var result = handler.Handle(commandPlan); Assert.AreNotEqual(null, result); Assert.AreEqual(true, handler.Valid); }
public async Task <IActionResult> CreatePlan(CreatePlanCommand createPlanCommand) { var result = await Mediator.Send(createPlanCommand); if (result.Success == false) { return(result.ApiResult); } return(Created(Url.Link("GetPlanInfo", new { id = result.Data.Id }), result.Data)); }
public Plan Create(CreatePlanCommand command) { var plan = new Plan(command.ValueEquipmentMain, command.ValueEquipmentAdditional, command.ValueUpdate, command.Description, command.Title); plan.Create(); _repository.Create(plan); if (Commit()) { return(plan); } return(null); }
public Task <HttpResponseMessage> Post([FromBody] dynamic body) { decimal value = Convert.ToDecimal(body.value); var command = new CreatePlanCommand( valueEquipmentMain: (decimal)body.valueEquipmentMain, valueEquipmentAdditional: (decimal)body.valueEquipmentAdditional, valueUpdate: (decimal)body.valueUpdate, description: (string)body.description, title: (string)body.title ); var plan = _service.Create(command); return(CreateResponse(HttpStatusCode.Created, plan)); }
public async Task <IActionResult> CreatePlan(CreatePlanCommand command) { return(Ok(await Mediator.Send(command))); }