public ICommandResult Execute(DeleteFabricanteCommand command) { var Fabricante = FabricanteRepository.GetById(command.Id); FabricanteRepository.Delete(Fabricante); unitOfWork.Commit(); return(new CommandResult(true)); }
public HttpResponseMessage Get([FromUri] int 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; } Fabricante _fabricante = fabricanteRepository.GetById(include, (p => p.Id == Id)); if (cultura != Localizacion.CulturaPorDefecto) { Fabricante_Idioma _fabricanteIdioma = fabricante_IdiomaRepository.GetMany(p => p.IdRegistro == Id && p.Cultura == cultura).FirstOrDefault(); // Campos multiidioma if (_fabricanteIdioma != null) { _fabricante.Nombre = _fabricanteIdioma.Nombre; } } if (_fabricante == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } return(Request.CreateResponse <Fabricante>(HttpStatusCode.OK, _fabricante, formatter)); } catch (Exception _excepcion) { log.Error(_excepcion); return(Request.CreateResponse(HttpStatusCode.InternalServerError, _excepcion)); } }