public static bool CancelContractScopeIsValid(this Contract contract, CancelContractCommand command) { return(AssertionConcern.IsSatisfiedBy( //AssertionConcern.AssertNotEmpty(command.Note, "É preciso informar o motivo do cancelamento do contrato"), //AssertionConcern.AssertLength(command.Note, 8, 2000, "Tamanho do texto inválido") )); }
public Task <HttpResponseMessage> Cancel([FromBody] dynamic body) { var command = new CancelContractCommand( idContract: (int)body.idContract, idCompany: (int)body.idCompany, //idPlan: (int)body.idPlan, note: (string)body.note ); var contract = _service.Cancel(command); return(CreateResponse(HttpStatusCode.OK, contract)); }
public void CancelContract(CancelContractCommand command) { if (!this.CancelContractScopeIsValid(command)) { return; } this.IdCompany = command.IdContract; //this.IdPlan = command.IdPlan; this.DateEnd = command.DateEnd; this.StatusContract = command.StatusContract; this.Note = command.Note; }
public Contract Cancel(CancelContractCommand command) { var contract = _repository.GetById(command.IdContract); contract.CancelContract(command); if (Commit()) { return(contract); } return(null); }