public HttpResponseMessage PendurarMalote(Malote obj) { var context = new AlvoradaContext(); try { obj.DtRecebimento = DateTime.Now; context.Entry(obj).State = EntityState.Modified; var log = new MaloteLog { IdMalote = obj.Id, DataLog = DateTime.Now, IdUsuario = obj.IdUsuarioRecebimento.Value, Status = obj.Status }; context.MalotesLog.Add(log); context.SaveChanges(); } catch (Exception ex) { throw ex; } return(Request.CreateResponse(HttpStatusCode.OK)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Numero,Percurso,Lacre,Cidade,Remetente,Status,Atualizacao,DataEnvio,DataRecebido,CidadeSaida,NomeUser")] Malote malote) { if (id != malote.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(malote); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MaloteExists(malote.Id)) { return(NotFound()); } else { throw; } } var remetente = c.EmailUser(User.Identity.Name); mail.atualizaMalote(malote.Status, malote.DataEnvio, malote.Cidade, malote.Numero, malote.Percurso, malote.Lacre, malote.Remetente, remetente); TempData["mensagemEdit"] = "MSG"; return(RedirectToAction(nameof(Index))); } ViewBag.NomeUser = c.NomeUser(User.Identity.Name); return(View(malote)); }
public async Task <IActionResult> Create([Bind("Id,Numero,Percurso,Lacre,Cidade,Remetente,Status,Atualizacao,DataEnvio,DataRecebido,CidadeSaida,NomeUser")] Malote malote) { if (ModelState.IsValid) { _context.Add(malote); await _context.SaveChangesAsync(); TempData["mensagemCreate"] = "MSG"; var remetente = c.EmailUser(User.Identity.Name); mail.enviaMalote(malote.Status, malote.DataEnvio, malote.Cidade, malote.Numero, malote.Percurso, malote.Lacre, malote.Remetente, remetente); return(RedirectToAction(nameof(Index))); } ViewBag.NomeUser = c.NomeUser(User.Identity.Name); return(View(malote)); }
public HttpResponseMessage AlterarMalote(Malote obj) { var context = new AlvoradaContext(); try { context.Entry(obj).State = EntityState.Modified; context.SaveChanges(); } catch (Exception ex) { throw ex; } return(Request.CreateResponse(HttpStatusCode.OK)); }
public HttpResponseMessage IncluirMaloteDeposito(Malote obj) { var context = new AlvoradaContext(); try { obj.DtEnvio = DateTime.Now; obj.Status = 4; context.Malotes.Add(obj); context.SaveChanges(); } catch (Exception ex) { throw ex; } return(Request.CreateResponse(HttpStatusCode.OK)); }