public IHttpActionResult PostParo(Paro paro) { paro.FechaReporte = DateTime.Now; paro.Activo = true; paro.ActividadesEnParo = new List <ActividadEnParo> { new ActividadEnParo { Fecha = DateTime.Now, Descripcion = "Nueva Falla reportada!!", IdPersona = paro.IdReportador } }; paro.TiemposDeParo = new List <TiempoDeParo> { new TiempoDeParo { Inicio = DateTime.Now } }; ParoServicio servicio = new ParoServicio(db); var respuesta = servicio.PostParo(paro); NotificationService notify = new NotificationService(); UsuarioServicio usuarioServicio = new UsuarioServicio(); List <DispositivoView> dispositivos = usuarioServicio.GetMecanicosPorOrigen(paro.IdOrigen); List <string> llaves = dispositivos.Select(x => x.Llave).ToList(); foreach (string notificacion in llaves) { //notify.SendPushNotification(notificacion, "El modulo " + paroAdded.Origen.Modulo.NombreCorto + " necesita de tu ayuda urgentemente.", "Nueva Falla reportada en " + paroAdded.Origen.WorkCenter.NombreCorto + " por favor ve lo mas pronto posible a ayudarlos."); } return(Ok(respuesta)); }
public void PostParoTest() { Paro paro = new Paro(); paro.FechaReporte = DateTime.Now; paro.IdReportador = 66; paro.IdOrigen = 1; paro.TiemposDeParo = new List <TiempoDeParo> { new TiempoDeParo() { Inicio = DateTime.Now } }; paro.ActividadesEnParo = new List <ActividadEnParo> { new ActividadEnParo() { Fecha = DateTime.Now, IdPersona = paro.IdReportador, Descripcion = "Ejemplo Cargado Con UnitTest", } }; var respuesta = _servicio.PostParo(paro); Assert.IsTrue(respuesta.EjecucionCorrecta); }