Example #1
0
        public static void DeleteSegment(Segment segment)
        {
            if (sqlConnection.State == ConnectionState.Closed) sqlConnection.Open();
            //SqlCommand command = new SqlCommand("Delete from " + databaseName + ".segmentsurveys where SequenceId='" + segment.SequenceId + "' and roadid='" + segment.RoadId + "'", sqlConnection);
            //try
            //{
            //    var result = command.ExecuteReaderAsync();
            //    sqlConnection.Close();
            //}
            //catch (Exception ex)
            //{
            //    ex.ToString();
            //}
            //if (sqlConnection.State == ConnectionState.Closed) sqlConnection.Open();
            //SqlCommand command_deleteSegments = new SqlCommand("DELETE FROM " + databaseName + ".segments where InventId='" + segment.InventId + "'", sqlConnection);
            //try
            //{
            //    var sql_result = command_deleteSegments.ExecuteReader();
            //    sqlConnection.Close();
            //}
            //catch (Exception e)
            //{
            //    e.ToString();
            //}

            DeleteSurveysByInventId(segment.InventId);
            segment.isDeleted = true;
            EditSegment(segment);
        }
Example #2
0
 public async Task<ViewResult> Create(string RoadId)
 {
     Segment seg = new Segment();
     var curUser = UserManager.FindById(User.Identity.GetUserId());
     seg.RoadId = RoadId;
     ViewBag.placeName = curUser.PlaceName;
     var _road= await ApiHelper.GetRoadById(RoadId);
     ViewBag.roadName = _road.Name;
     return View(seg);
 }
Example #3
0
 public async Task TestGetSegmentSurveysBySegment()
 {
     var segment = new Segment() {InventId = 77};
     var hist = await ApiHelper.GetSegmentSurveysBySegment(segment);
     Assert.IsNotNull(hist);
 }
Example #4
0
        public static void EditSegment(Segment segment)
        {
            if (sqlConnection.State == ConnectionState.Closed) sqlConnection.Open();
            object sql_result;
            string fro = @"""From""";
            string to = @"""To""";
            string command_text = "update " + databaseName + ".segments SET sequenceId = '" + segment.SequenceId + "'," + fro + "='" + segment.From + "'," + to + "='" + segment.To + "',hasCurbOrGutter='" + segment.HasCurbOrGutter + "',remarks='" + segment.Remarks + "', inventId='" + segment.InventId + "', isdeleted='" + segment.isDeleted + "' WHERE inventId='" + segment.InventId + "'";
            SqlCommand command = new SqlCommand(command_text, sqlConnection);
            try
            {
                sql_result = command.ExecuteReader();
                var re = sql_result;
                sqlConnection.Close();
            } catch (Exception e)
            {
                e.ToString();
            }

        }
 public SegmentSurveyViewModel(List<SegmentSurvey> Surys, Segment Seg)
 {
     SegmentSurveys = Surys;
     Segment = Seg;
 }
Example #6
0
 public static async Task<List<SegmentSurvey>> GetSegmentSurveysBySegment(Segment segment)
 {
     var url = String.Format("tables/segmentsurvey?$filter=inventId eq {0}", segment.InventId);
     var response = await Client.GetAsyncWithCred(url);
     return (JsonConvert.DeserializeObject<List<SegmentSurvey>>(response)).OrderBy(ss => ss.SegSurveyDate).ToList();
 }
Example #7
0
        public static async Task CreateSegment(Segment segment)
        {
            try
            {
                string theUri = BaseURL + "tables/segment";
                String jsonSer = JsonConvert.SerializeObject(segment);
                HttpContent payload = new StringContent(jsonSer, System.Text.Encoding.UTF8, "application/json");
                var aResponse = await Client.PostAsync(theUri, payload);
            }
            catch (System.Net.WebException ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadLine();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
                Console.Read();
            }

        }
Example #8
0
        //public static Task DeleteSegmentSurveyByID(string id)
        //{
        //    //try
        //    //{
        //    //    var url = BaseURL + String.Format("tables/segmentsurvey/{0}", id);
        //    //    var aResponse = await Client.DeleteAsync(url);
        //    //    var result = aResponse;
        //    //}
        //    //catch (Exception ex)
        //    //{
        //    //    var errorMessage = ex.ToString();
        //    //}

        //     DataTools.DeleteSurveyByID(id);

        //}


        public static void EditSegment(Segment segment)
        {
            try
            {
                DataTools.EditSegment(segment);
            }
            catch (System.Net.WebException ex)
            {
                Console.WriteLine(ex.ToString());
                Console.ReadLine();
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception.ToString());
                Console.Read();
            }
        }