예제 #1
0
        public static bool AddAgentTrack(DataAccess.Entities.TrackAgent track)
        {
            DtDAgentTrack newTrack  = new DtDAgentTrack();
            bool          savetrack = true;

            newTrack.AgentId     = track.AgentId;
            newTrack.Geolocation = DbGeography.FromText($"Point({track.Geolocation.lng} {track.Geolocation.lat})");
            try
            {
                using (CustomClearviewEntities ctx = new CustomClearviewEntities())
                {
                    DtDAgentTrackRepository repo = new DtDAgentTrackRepository(ctx);
                    repo.Create(newTrack);
                    ctx.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                savetrack = false;
            }
            return(savetrack);
        }
예제 #2
0
        public IHttpActionResult DTDTrackAgent(DataAccess.Entities.TrackAgent TrackAgent)
        {
            bool          hasErrors = false;
            bool          agentTrack;
            List <string> errorList = new List <string>();
            List <DataAccess.Infrastructure.DtDAgentTrack> tracking = null;

            try
            {
                agentTrack = Business.AppLogic.AddAgentTrack(TrackAgent);
            }
            catch (Exception ex)
            {
                hasErrors = true;
                errorList.Add(ex.Message);
            }
            return(Ok(new ViewModel.ApiMessage <List <DataAccess.Infrastructure.DtDAgentTrack> >
            {
                Data = tracking,
                HasErrors = hasErrors,
                ErrorList = errorList
            }));
        }