public IHttpActionResult PostMotivoNoEntrega(MotivoNoEntrega motivoNoEntrega) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.MotivoNoEntregas.Add(motivoNoEntrega); MarcacionEntrega marcacion_asociada = db.MarcacionEntregas.FirstOrDefault(x => x.Id == motivoNoEntrega.MarcacionId); OrdenEntrega orden_asociada = db.OrdenEntregas.FirstOrDefault(x => x.Id == marcacion_asociada.OrdenEntregaId); orden_asociada.Estado = "NEntregado"; //A Prueba var hub = GlobalHost.ConnectionManager.GetHubContext <hubPrueba>(); hub.Clients.All.actualizar("Se actualizo No Entrega"); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = motivoNoEntrega.Id }, motivoNoEntrega)); }
public async Task <IHttpActionResult> PostMotivoNoEntrega(MotivoNoEntrega motivoNoEntrega) { if (motivoNoEntrega == null) { return(BadRequest("El modelo esta vacio")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.MotivosNoEntrega.Add(motivoNoEntrega); MarcacionEntrega marcacionEntrega = db.MarcacionesEntrega.FirstOrDefault(x => x.Id == motivoNoEntrega.MarcacionEntregaId); OrdenEntrega orden = db.OrdenesEntrega.FirstOrDefault(x => x.Id == marcacionEntrega.OrdenEntregaId); orden.Estado = "No Entregado"; await db.SaveChangesAsync(); var hubContext = GlobalHost.ConnectionManager.GetHubContext <hubPrueba>(); hubContext.Clients.All.Send("actualizarEntregas"); await db.SaveChangesAsync(); return(CreatedAtRoute("DefaultApi", new { id = motivoNoEntrega.Id }, motivoNoEntrega)); }
public IHttpActionResult PutMotivoNoEntrega(int id, MotivoNoEntrega motivoNoEntrega) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != motivoNoEntrega.Id) { return(BadRequest()); } db.Entry(motivoNoEntrega).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!MotivoNoEntregaExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public async Task <IHttpActionResult> GetMotivoNoEntrega(int id) { MotivoNoEntrega motivoNoEntrega = await db.MotivosNoEntrega.FindAsync(id); if (motivoNoEntrega == null) { return(NotFound()); } return(Ok(motivoNoEntrega)); }
public IHttpActionResult GetMotivoNoEntrega(int id) { MotivoNoEntrega motivoNoEntrega = db.MotivoNoEntregas.Find(id); if (motivoNoEntrega == null) { return(NotFound()); } return(Ok(motivoNoEntrega)); }
public async Task <ActionResult> Delete(int?id) { MotivoNoEntrega registro = new MotivoNoEntrega(); if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } registro = await motivosService.obtenerMotivoNoEntrega(id); return(View(registro)); }
public async Task <ActionResult> AddorEdit(int id = 0) { if (id == 0) { return(View(new MotivoNoEntrega())); } else { MotivoNoEntrega motivo = await motivosService.obtenerMotivoNoEntrega(id); return(View(motivo)); } }
public async Task <IHttpActionResult> DeleteMotivoNoEntrega(int id) { MotivoNoEntrega motivoNoEntrega = await db.MotivosNoEntrega.FindAsync(id); if (motivoNoEntrega == null) { return(NotFound()); } db.MotivosNoEntrega.Remove(motivoNoEntrega); await db.SaveChangesAsync(); return(Ok(motivoNoEntrega)); }
public IHttpActionResult DeleteMotivoNoEntrega(int id) { MotivoNoEntrega motivoNoEntrega = db.MotivoNoEntregas.Find(id); if (motivoNoEntrega == null) { return(NotFound()); } db.MotivoNoEntregas.Remove(motivoNoEntrega); db.SaveChanges(); return(Ok(motivoNoEntrega)); }
public async Task <MotivoNoEntrega> eliminarMotivoNoEntrega(int?id) { using (HttpResponseMessage response = await Helpers.ConnectionHelper.httpClient.DeleteAsync(urlBase + id.ToString())) { if (response.IsSuccessStatusCode) { MotivoNoEntrega registro = response.Content.ReadAsAsync <MotivoNoEntrega>().Result; return(registro); } else { throw new Exception(response.ReasonPhrase); } } }
public async Task <MotivoNoEntrega> adicionarMotivoNoEntrega(MotivoNoEntrega motivo) { using (HttpResponseMessage response = await Helpers.ConnectionHelper.httpClient.PostAsJsonAsync(urlBase, motivo)) { if (response.IsSuccessStatusCode) { MotivoNoEntrega registro = response.Content.ReadAsAsync <MotivoNoEntrega>().Result; return(registro); } else { throw new Exception(response.ReasonPhrase); } } }
public async Task <ActionResult> AddorEdit(MotivoNoEntrega motivo) { if (motivo.Id == 0) { await motivosService.adicionarMotivoNoEntrega(motivo); TempData["SuccessMessage"] = "Saved Successfully"; } else { await motivosService.modificarMotivoNoEntrega(motivo.Id, motivo); TempData["SuccessMessage"] = "Updated Successfully"; } return(RedirectToAction("Index")); }
public async Task <IHttpActionResult> PutMotivoNoEntrega(int id, MotivoNoEntrega motivoNoEntrega) { if (motivoNoEntrega == null) { return(BadRequest("El modelo esta vacio")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != motivoNoEntrega.Id) { return(BadRequest()); } db.Entry(motivoNoEntrega).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MotivoNoEntregaExists(id)) { return(NotFound()); } else { throw; } } MotivoNoEntrega m = db.MotivosNoEntrega.Find(id); return(Ok(m)); //return StatusCode(HttpStatusCode.NoContent); }