public async Task <IActionResult> Update([FromBody] UpdateDepartament command, int id)
        {
            command.Id = id;

            Result <Departament> result = await Mediator.Send(command);

            return(As(result, MapTo <DepartamentDto>));
        }
Example #2
0
        public async Task <Result <Departament> > Handle(UpdateDepartament command)
        {
            if (command == null)
            {
                throw Error.ArgumentNull(nameof(command));
            }

            var productResult = await repository.GetById(command.Id);

            if (productResult.IsFailure)
            {
                return(productResult);
            }

            var departament = productResult.Value;

            departament.Apply(command);

            await auditService.RegisterUpdate(departament);

            await repository.Update(departament);

            return(Result.Ok(departament));
        }
Example #3
0
 public void Apply(UpdateDepartament command)
 {
     Title       = command.Title;
     Description = command.Description;
 }