コード例 #1
0
        public IHttpActionResult SetUbicaciones(List <Services.General.Models.Ubicacion> ubicaciones)
        {
            try
            {
                long newId = DataBase.AgenteUbicaciones.GetMaxValue <long>(p => p.IdAgenteUbicacion, 0) + 1;

                var agente = DataBase.Agentes.Get(p => p.Usuario.LogonName == CurrentUser.LogonName).FirstOrDefault();
                if (agente != null)
                {
                    foreach (var ubicacion in ubicaciones)
                    {
                        var model = new AgendaComercial.Models.Ruta.AgenteUbicacion();

                        model.IdAgente = agente.IdAgente;
                        model.Latitud  = ubicacion.Latitud;
                        model.Longitud = ubicacion.Longitud;
                        model.Fecha    = ubicacion.Fecha;

                        model.IdAgenteUbicacion = newId;

                        DataBase.AgenteUbicaciones.Insert(model);
                        newId++;
                    }
                    DataBase.Save();
                }
            }
            catch
            {
                return(BadRequest());
            }

            return(Ok());
        }
コード例 #2
0
        public IHttpActionResult SetUbicacion(float latitud, float longitud)
        {
            try
            {
                var agente = DataBase.Agentes.Get(p => p.Usuario.LogonName == CurrentUser.LogonName).FirstOrDefault();

                if (agente != null)
                {
                    var model = new AgendaComercial.Models.Ruta.AgenteUbicacion();

                    model.IdAgente = agente.IdAgente;
                    model.Latitud  = latitud;
                    model.Longitud = longitud;
                    model.Fecha    = Rp3.Web.Mvc.Session.CurrentDateTime;
                    model.AsignarId();

                    DataBase.AgenteUbicaciones.Insert(model);

                    DataBase.Save();
                }
            }
            catch
            {
                return(BadRequest());
            }

            return(Ok());
        }