Esempio n. 1
0
        public ICommandResult Execute(DeleteTipoEventoCommand command)
        {
            var TipoEvento = TipoEventoRepository.GetById(command.Id);

            TipoEventoRepository.Delete(TipoEvento);
            unitOfWork.Commit();
            return(new CommandResult(true));
        }
Esempio n. 2
0
        public HttpResponseMessage Get([FromUri] short Id, [FromUri] string cultura, [FromUri] string[] include, [FromUri] bool indent = false)
        {
            try {
                var formatter = new MaxDepthJsonMediaTypeFormatter()
                {
                    Indent = indent
                };
                if (include.Length > 0)
                {
                    formatter.SerializerSettings.MaxDepth = 100;                     //include.Max<string>(s => s.Split('.').Length * 5);
                    formatter.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;
                }
                else
                {
                    formatter.SerializerSettings.MaxDepth = 1;
                }
                TipoEvento _tipoevento = tipoeventoRepository.GetById(include, (p => p.Id == Id));
                if (cultura != Localizacion.CulturaPorDefecto)
                {
                    TipoEvento_Idioma _tipoeventoIdioma = tipoevento_IdiomaRepository.GetMany(p => p.IdRegistro == Id && p.Cultura == cultura).FirstOrDefault();

                    // Campos multiidioma
                    if (_tipoeventoIdioma != null)
                    {
                        _tipoevento.Nombre = _tipoeventoIdioma.Nombre;
                    }
                }

                if (_tipoevento == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
                return(Request.CreateResponse <TipoEvento>(HttpStatusCode.OK, _tipoevento, formatter));
            } catch (Exception _excepcion) {
                log.Error(_excepcion);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, _excepcion));
            }
        }