public RetornoGlobal <ButtonsMenuModel> PutMenu(UpdateMenuCommand parameter)
        {
            RetornoGlobal <ButtonsMenuModel> retorno = new RetornoGlobal <ButtonsMenuModel>();

            try
            {
                UpdateMenuValidator validacao = new UpdateMenuValidator(contexto);
                var result = validacao.Validate(parameter);
                if (result.IsValid)
                {
                    var registro = this.contexto.TabelaButtonsMenu.Where(r => r.Id == parameter.Id).First();
                    registro.description = parameter.description;
                    registro.href        = parameter.href;
                    contexto.SaveChanges();

                    retorno.status        = true;
                    retorno.RetornoObjeto = registro;
                }
                else
                {
                    retorno.status = false;
                    result.Errors.ToList().ForEach(r =>
                                                   retorno.errors.Add(r.ToString())
                                                   );
                }
            }
            catch (Exception e) {
                retorno.status = false;
                retorno.errors.Append(e.Message);
                retorno.errors.Append(e.InnerException.ToString());
            }
            return(retorno);
        }
示例#2
0
 public UpdateMenuInputModel()
 {
     _validator = new UpdateMenuValidator();
 }