public static bool UpdatePlanScopeIsValid(this Plan plan, UpdatePlanCommand newPlan) { return(AssertionConcern.IsSatisfiedBy( AssertionConcern.AssertNotEmpty(newPlan.Description, "A descrição é obrigatória"), AssertionConcern.AssertNotEmpty(newPlan.Title, "O titulo é obrigatório"), AssertionConcern.AssertTrue(!(newPlan.ValueEquipmentAdditional == 0), "O valor do equipamento adicional é obrigatório"), AssertionConcern.AssertTrue(!(newPlan.ValueEquipmentMain == 0), "O valor do equipamento principal é obrigatório") )); }
public async Task <IActionResult> UpdatePlan(UpdatePlanCommand updatePlanCommand) { var result = await Mediator.Send(updatePlanCommand); if (result.Success == false) { return(result.ApiResult); } return(NoContent()); }
public void Update(UpdatePlanCommand command) { if (!this.UpdatePlanScopeIsValid(command)) { return; } this.Description = command.Description; this.Title = command.Title; this.ValueEquipmentAdditional = command.ValueEquipmentAdditional; this.ValueEquipmentMain = command.ValueEquipmentMain; this.ValueUpdate = command.ValueUpdate; }
public Plan Update(UpdatePlanCommand command) { var plan = _repository.GetById(command.IdPlan); plan.Update(command); _repository.Update(plan); if (Commit()) { return(plan); } return(null); }
public Task <HttpResponseMessage> Put(int id, [FromBody] dynamic body) { var command = new UpdatePlanCommand( idPlan: id, valueEquipmentMain: (decimal)body.valueEquipmentMain, valueEquipmentAdditional: (decimal)body.valueEquipmentAdditional, valueUpdate: (decimal)body.valueUpdate, description: (string)body.description, title: (string)body.title ); var plan = _service.Update(command); return(CreateResponse(HttpStatusCode.OK, plan)); }