Пример #1
0
        public IComandResult Alterar([FromBody] AlterarRotinaCommands command)
        {
            var user = Guid.Parse(this.User.Identity.Name);

            //var user = Guid.Parse("781503e9-272b-4251-8fdf-77aca5f2d57a");
            command.SetarUsuarioId(user);
            var result = (ComandResult)_rotinaHandler.Handle(command);

            this.Commit(result.Success);
            return(result);
        }
Пример #2
0
        public IComandResult Handle(AlterarRotinaCommands comand)
        {
            //verificar se tem notificação no comand
            if (!comand.IsValid())
            {
                return(new ComandResult(false, "Por favor corrija os campos abaixo", comand.Notifications));
            }

            var rotina = _repository.Existe(comand.RotinaId, comand.UsuarioId);

            if (rotina != null)
            {
                rotina.Alterar(comand.De, comand.Ate, comand.SerieId);
                _repository.Alterar(rotina);
            }
            else
            {
                return(new ComandResult(false, "Rotina não encontrada!!,tente novamente!!", new { }));
            }

            return(new ComandResult(true, "Dados Alterados com Sucesso!!", new { }));
        }