Example #1
0
 public ActionResult EditPC(int id, PuntoControl collection)
 {
     try
     {
         var client  = new RestClient(Direcciones.ApiRest + "trayecto/editpuntocontrol");
         var request = new RestRequest(Method.PUT);
         request.AddHeader("content-type", "application/json");
         request.AddHeader("Authorization", "Bearer " + Request.Cookies["Token"].Value);
         request.AddJsonBody(collection);
         IRestResponse response = client.Execute(request);
         if (response.StatusCode.ToString() == "OK")
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             ViewBag.ERROR = response.Content;
         }
         return(CreatePC(collection.IdTrayecto));
     }
     catch (Exception e)
     {
         ViewBag.ERROR = e.Message;
         return(CreatePC(collection.IdTrayecto));
     }
 }
Example #2
0
 public PuntoControl entidadAModelo(SPuntoControl p, PuntoControl pc)
 {
     pc.id         = (int)p.Id;
     pc.idTrayecto = (int)p.IdTrayecto;
     pc.orden      = p.Orden;
     pc.tiempo     = p.Tiempo;
     pc.borrado    = p.Borrado;
     pc.nombre     = p.Nombre;
     if (p.IdAgencia != null)
     {
         pc.idAgencia = p.IdAgencia;
     }
     return(pc);
 }
Example #3
0
 public SPuntoControl addPuntoControl(SPuntoControl a)
 {
     using (trackingFULLEntities en = new trackingFULLEntities())
     {
         try
         {
             PuntoControl ag = en.PuntoControl.Add(_conv.entidadAModelo(a));
             en.SaveChanges();
             return(_conv.modeloAEntidad(ag));
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Example #4
0
        public string deletePuntoControl(int id)
        {
            using (trackingFULLEntities en = new trackingFULLEntities())
            {
                try
                {
                    PuntoControl a = en.PuntoControl.Find(id);
                    a.borrado = true;
                    en.SaveChanges();

                    return(null);
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }
Example #5
0
 public bool isActive(int id)
 {
     using (trackingFULLEntities en = new trackingFULLEntities())
     {
         try
         {
             PuntoControl a = en.PuntoControl.Find(id);
             if ((bool)a.borrado)
             {
                 return(false);
             }
             return(true);
         }
         catch (Exception)
         {
             throw;
         }
     }
 }
Example #6
0
 public ActionResult EditPC(int id)
 {
     try
     {
         var client  = new RestClient(Direcciones.ApiRest + "trayecto/getpuntocontrol");
         var request = new RestRequest(Method.GET);
         request.AddHeader("content-type", "application/json");
         request.AddHeader("Authorization", "Bearer " + Request.Cookies["Token"].Value);
         request.AddQueryParameter("id", id.ToString());
         IRestResponse response = client.Execute(request);
         if (response.StatusCode.ToString() == "OK")
         {
             PuntoControl pc = JsonConvert.DeserializeObject <PuntoControl>(response.Content);
             client  = new RestClient(Direcciones.ApiRest + "agencia");
             request = new RestRequest(Method.GET);
             request.AddHeader("content-type", "application/json");
             request.AddHeader("Authorization", "Bearer " + Request.Cookies["Token"].Value);
             response = client.Execute(request);
             if (response.StatusCode.ToString() == "OK")
             {
                 ViewBag.AGENCIAS = JsonConvert.DeserializeObject <List <Models.Agencia> >(response.Content);
                 return(View(pc));
             }
             else
             {
                 ViewBag.ERROR = response.Content;
             }
             return(View());
         }
         else
         {
             ViewBag.ERROR = response.Content;
         }
         return(View());
     }
     catch (Exception e)
     {
         ViewBag.ERROR = e.Message;
         return(View());
     }
 }
Example #7
0
        public PuntoControl entidadAModelo(SPuntoControl p)
        {
            PuntoControl puntoControl = new PuntoControl()
            {
                idTrayecto = p.IdTrayecto,
                orden      = p.Orden,
                tiempo     = p.Tiempo,
                borrado    = p.Borrado,
                nombre     = p.Nombre
            };

            if (p.Id != null)
            {
                puntoControl.id = (int)p.Id;
            }
            if (p.IdAgencia != null)
            {
                puntoControl.idAgencia = p.IdAgencia;
            }
            return(puntoControl);
        }
Example #8
0
        //PUNTO DE CONTROL

        public SPuntoControl modeloAEntidad(PuntoControl p)
        {
            if (p == null)
            {
                return(null);
            }
            SPuntoControl puntoControl = new SPuntoControl()
            {
                Id         = p.id,
                IdTrayecto = (int)p.idTrayecto,
                Orden      = (int)p.orden,
                Tiempo     = (int)p.tiempo,
                Borrado    = (bool)p.borrado,
                Nombre     = p.nombre
            };

            if (p.idAgencia != null)
            {
                puntoControl.IdAgencia = p.idAgencia;
            }
            return(puntoControl);
        }