コード例 #1
0
ファイル: DAL_imp.cs プロジェクト: MOSHE110/wpf_2019_project
        }// done

        public bool RemoveDrop(int id)
        {
            try
            {
                using (var db = new Entitys())
                {
                    //var dropToRemove = (from d in db.Drops where d.Id == id select d).First();
                    //  var dropToRemove = (   from d in db.Drops where d.Drop_Id == id select d).FirstOrDefault();
                    // Load one blogs and its related posts
                    // var dropToRemove = db.Drops.Single(d => d.Drop_Id == id);
                    var dropToRemove = db.Drops
                                       .Where(d => d.Drop_Id == id)
                                       .Include(r => r.Reports_list)
                                       .FirstOrDefault();

                    db.Drops.Remove(dropToRemove);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }     // done
コード例 #2
0
ファイル: DAL_imp.cs プロジェクト: MOSHE110/wpf_2019_project
        public bool AddDrop(Drop drop)
        {
            try
            {
                using (var db = new Entitys())
                {
                    var newDropToAdd = new Drop
                    {
                        Id             = drop.Id,
                        Drop_Id        = drop.Drop_Id,
                        Drop_Adress    = drop.Drop_Adress,
                        Drop_time      = drop.Drop_time,
                        Reports_list   = drop.Reports_list,
                        Real_lat       = drop.Real_lat,
                        Real_log       = drop.Real_log,
                        Estimeated_lat = drop.Estimeated_lat,
                        Estimeated_log = drop.Estimeated_log,
                    };


                    db.Drops.Add(newDropToAdd);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }// done
コード例 #3
0
ファイル: DAL_imp.cs プロジェクト: MOSHE110/wpf_2019_project
        public bool AddReport(Report report)
        {
            try
            {
                using (var db = new Entitys())
                {
                    var newReportToAdd = new Report
                    {
                        Id            = report.Id,
                        Report_Id     = report.Report_Id,
                        Time          = report.Time,
                        Name          = report.Name,
                        Report_Adress = report.Report_Adress,
                        Boom_count    = report.Boom_count,
                        ImagePath     = report.ImagePath,
                        lat           = report.lat,
                        log           = report.log
                    };


                    db.Reports.Add(newReportToAdd);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        } //done
コード例 #4
0
ファイル: DAL_imp.cs プロジェクト: MOSHE110/M_N_Project
        }  // done

        public Drop GetDrop(int id)
        {
            //using (var db =  new Entitys())
            //{
            //    var drop = (from d in db.Drops where d.Drop_Id == id select d).First();
            //    return new Drop
            //    {
            //        Id = drop.Id,
            //        Drop_Id = drop.Drop_Id,
            //        Drop_Adress = drop.Drop_Adress,
            //        Drop_time = drop.Drop_time,
            //        Reports_list = drop.Reports_list,
            //        Real_lat = drop.Real_lat,
            //        Real_log = drop.Real_log,
            //        Estimeated_lat = drop.Estimeated_lat,
            //        Estimeated_log = drop.Estimeated_log,

            //    };
            //}
            using (var db = new Entitys())
            {
                var dropToReturn = (from d in db.Drops where d.Drop_Id == id select d).First();
                return(dropToReturn);
            }
        }        // done
コード例 #5
0
ファイル: DAL_imp.cs プロジェクト: MOSHE110/wpf_2019_project
        }  // done

        public Drop GetDrop(int id)
        {
            using (var db = new Entitys())
            {
                var dropToReturn = (from d in db.Drops where d.Drop_Id == id select d).First();
                return(dropToReturn);
            }
        }        // done
コード例 #6
0
        }        // done

        public List <Drop> getDropList()
        {
            using (var db = new  Entitys())
            {
                var drops = (from d in db.Drops select d);
                return(drops.ToList <Drop>());
            }
        }
コード例 #7
0
 public List <Report> getReportList()
 {
     using (var db = new Entitys())
     {
         var drops = (from d in db.Reports select d);
         return(drops.ToList <Report>());
         //return null;
     }
 }//done
コード例 #8
0
ファイル: DAL_imp.cs プロジェクト: MOSHE110/wpf_2019_project
        }     // done

        public bool UpdateDrop(Drop Drop)
        {
            try
            {
                using (var db = new Entitys())
                {
                    var dropToUpdate = (from d in db.Drops
                                        where d.Drop_Id == Drop.Drop_Id
                                        select d).First();
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }  // done
コード例 #9
0
ファイル: DAL_imp.cs プロジェクト: MOSHE110/wpf_2019_project
        }// done

        public bool RemoveReport(int id)
        {
            try
            {
                using (var db = new Entitys())
                {
                    var reportToRemove = (from r in db.Reports where r.Report_Id == id select r).First();

                    db.Reports.Remove(reportToRemove);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }//done
コード例 #10
0
ファイル: DAL_imp.cs プロジェクト: MOSHE110/wpf_2019_project
        } //done

        public bool UpdateReport(Report Report)
        {
            try
            {
                using (var db = new Entitys())
                {
                    var ReportToUpdate = (from r in db.Reports
                                          where r.Report_Id == Report.Report_Id
                                          select r).First();
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }// done
コード例 #11
0
ファイル: DAL_imp.cs プロジェクト: MOSHE110/wpf_2019_project
        }//done

        public Report GetReport(int id)
        {
            using (var db = new Entitys())
            {
                var report = (from r in db.Reports
                              where r.Report_Id == id
                              select r).FirstOrDefault();
                return(new Report
                {
                    Id = report.Id,
                    Report_Id = report.Report_Id,
                    Time = (DateTime)report.Time,
                    Name = report.Name,
                    Report_Adress = report.Report_Adress,
                    Boom_count = report.Boom_count,
                    ImagePath = report.ImagePath,
                    lat = report.lat,
                    log = report.log,
                });
            }
        }
コード例 #12
0
        }  // done

        public Drop GetDrop(int id)
        {
            ////////////////////////////
            /////////////////////////////
            //using (DbConnection connection = new SqlConnection(@"data source=LAPTOP-438HUAJF\SQLEXPRESS; initial catalog=wpf_MVVM_EntityFramework;integrated security=SSPI"))
            //{
            //    connection.Open();
            //    using (DbCommand command = new SqlCommand("alter table [Drops] DROP COLUMN  [ImagePath]  "))
            //    {
            //        command.Connection = connection;
            //        command.ExecuteNonQuery();
            //    }
            //}
            ///////////////////////////
            ///////////////////////////
            //using (var db =  new Entitys())
            //{
            //    var drop = (from d in db.Drops where d.Drop_Id == id select d).First();
            //    return new Drop
            //    {
            //        Id = drop.Id,
            //        Drop_Id = drop.Drop_Id,
            //        Drop_Adress = drop.Drop_Adress,
            //        Drop_time = drop.Drop_time,
            //        Reports_list = drop.Reports_list,
            //        Real_lat = drop.Real_lat,
            //        Real_log = drop.Real_log,
            //        Estimeated_lat = drop.Estimeated_lat,
            //        Estimeated_log = drop.Estimeated_log,

            //    };
            //}
            using (var db = new Entitys())
            {
                var dropToReturn = (from d in db.Drops where d.Drop_Id == id select d).First();
                return(dropToReturn);
            }
        }        // done