public IHttpActionResult PutObra(int id, Obra obra) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != obra.Id) { return(BadRequest()); } db.Entry(obra).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!ObraExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutGeneroObraDescricao(int id, GeneroObraDescricao generoObraDescricao) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != generoObraDescricao.Id) { return(BadRequest()); } db.Entry(generoObraDescricao).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GeneroObraDescricaoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PutRegistroTransmissao(int id, RegistroTransmissao registroTransmissao) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != registroTransmissao.Id) { return(BadRequest()); } db.Entry(registroTransmissao).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!RegistroTransmissaoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
static void Main(string[] args) { while (true) { var db = new AuthoriunContext(); var transac = new Transacoes(); foreach (Registro r in db.Registro.Where(x => x.Status == 1).ToList()) { var hash = transac.CriarTransacoesAsync(r.Arquivo.SHA256, r.Arquivo.SHA256); var tp = hash.Result; if (string.IsNullOrWhiteSpace(tp.Item1)) { r.Status = 3; } else { r.HashTransacao = tp.Item1; r.CriadoEm = tp.Item2; r.Status = 2; } db.Entry(r).State = EntityState.Modified; } db.SaveChanges(); } }
public int PostRegistraObra(RegistraObraDTO registraObra) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} Registro registro = new Registro() { IdTenant = 1, //HashTransacao { get; set; } SolicitadoEm = DateTime.Now, Status = 1, CriadoPor = 1 //public DateTime CriadoEm { get; set; } }; Arquivo arquivo = new Arquivo() { IdTenant = 1, Nome = registraObra.Nome, Extensao = registraObra.Extensao, Mime = registraObra.Mime, Tamanho = registraObra.Tamanho, MD5 = registraObra.SHA256, SHA256 = registraObra.SHA256, SHA512 = registraObra.SHA256 //public string JWTCertificado { get; set; } //public string JWTChavePublica { get; set; } }; arquivo.Registro.Add(registro); Obra obra = new Obra() { IdTenant = 1, IdGeneroObra = registraObra.IdGeneroObra, EhRequerimento = true, Titulo = registraObra.Titulo, Grafica = registraObra.Grafica, Editora = registraObra.Editora, Ano = registraObra.Ano, Volume = registraObra.Volume, Edicao = registraObra.Edicao, LocalPublicacao = registraObra.LocalPublicacao, Paginas = registraObra.Paginas, Observacoes = registraObra.Observacoes, CriadoPor = 1, CriadoEm = DateTime.Now }; obra.Arquivo.Add(arquivo); db.Obra.Add(obra); db.SaveChanges(); //return CreatedAtRoute("DefaultApi", new //{ // id = obra.Id //}, obra); return(obra.Id); }