コード例 #1
0
 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")
                ));
 }
コード例 #2
0
ファイル: PlansController.cs プロジェクト: nosratiz/remosys
        public async Task <IActionResult> UpdatePlan(UpdatePlanCommand updatePlanCommand)
        {
            var result = await Mediator.Send(updatePlanCommand);

            if (result.Success == false)
            {
                return(result.ApiResult);
            }

            return(NoContent());
        }
コード例 #3
0
        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;
        }
コード例 #4
0
        public Plan Update(UpdatePlanCommand command)
        {
            var plan = _repository.GetById(command.IdPlan);

            plan.Update(command);
            _repository.Update(plan);

            if (Commit())
            {
                return(plan);
            }

            return(null);
        }
コード例 #5
0
        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));
        }