// Delete Personnel
 public ActionResult Delete(int ID)
 {
     try
     {
         var personnel = getPersonnel(ID);
         deletePersonnelFiles(personnel);
         db.Delete(personnel);
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         throw;
     }
 }
Пример #2
0
        private static void Crud()
        {
            var petaPoco = new PetaPoco.Database("Chinook");

            var customer = new Customer { FirstName = "Ian", LastName = "Russell", Email = "*****@*****.**" };

            petaPoco.Insert(customer);

            var id = customer.CustomerId;

            customer = petaPoco.Single<Customer>(id);

            ObjectDumper.Write(customer);

            customer.Country = "United Kingdom";

            petaPoco.Update(customer);

            customer = petaPoco.Single<Customer>(id);

            ObjectDumper.Write(customer);

            petaPoco.Delete<Customer>(id);

            customer = petaPoco.SingleOrDefault<Customer>(id);

            ObjectDumper.Write(customer);
        }
Пример #3
0
 public static bool DeleteLink(int id)
 {
     using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection"))
     {
         return(db.Delete <Models.Links>(id) > 0);
     }
 }
Пример #4
0
 public int DeleteEvent(OurEvent model)
 {
     using (PetaPoco.Database context = new PetaPoco.Database("DefaultConnection"))
     {
         return((int)context.Delete(model));
     }
 }
Пример #5
0
 public static void DeleteForum(int id)
 {
     using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection"))
     {
         db.Delete <Models.Forums>("WHERE fid=@0", id);
     }
 }
Пример #6
0
 public static bool DeleteCategory(int cid)
 {
     using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection"))
     {
         return(db.Delete(db.Query <Category>("where cid=@0", cid).SingleOrDefault()) > 0);
     }
 }
Пример #7
0
        private static void Crud()
        {
            var petaPoco = new PetaPoco.Database("Chinook");

            var customer = new Customer {
                FirstName = "Ian", LastName = "Russell", Email = "*****@*****.**"
            };

            petaPoco.Insert(customer);

            var id = customer.CustomerId;

            customer = petaPoco.Single <Customer>(id);

            ObjectDumper.Write(customer);

            customer.Country = "United Kingdom";

            petaPoco.Update(customer);

            customer = petaPoco.Single <Customer>(id);

            ObjectDumper.Write(customer);

            petaPoco.Delete <Customer>(id);

            customer = petaPoco.SingleOrDefault <Customer>(id);

            ObjectDumper.Write(customer);
        }
Пример #8
0
 public int DeleteLoveStory(OurLoveStory model)
 {
     using (PetaPoco.Database context = new PetaPoco.Database("DefaultConnection"))
     {
         return((int)context.Delete(model));
     }
 }
Пример #9
0
 public int DeleteEntityImage(EntityImage model)
 {
     using (PetaPoco.Database context = new PetaPoco.Database("DefaultConnection"))
     {
         return((int)context.Delete(model));
     }
 }
Пример #10
0
        public ActionResult delete(int id, Contacts home)
        {
            var dataContext = new PetaPoco.Database("sqladdress");

            dataContext.Delete <Contacts>(id);

            return(RedirectToAction("DBView"));
        }
Пример #11
0
 public void RemoveYeZhu(YeZhu yz)
 {
     if (Config.Conn.State == System.Data.ConnectionState.Closed)
     {
         Config.Conn.Open();
     }
     DB.Delete(yz);
 }
Пример #12
0
        public static void DeleteForum(int id)
        {
            using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection"))
            {
                db.Delete<Models.Forums>("WHERE fid=@0", id);

            }
        }
Пример #13
0
 public static bool DeleteUser(int uid)
 {
     using (PetaPoco.Database db = new PetaPoco.Database("sqlconnection"))
     {
         var model = db.Query <User>("Where uid=@0", uid).SingleOrDefault();
         return(db.Delete(model) > 0);
     }
 }
Пример #14
0
 public void DeleteMovie(int id)
 {
     using (var db = new PetaPoco.Database(ConnectionString, providerName))
     {
         var Movie = db.SingleOrDefault <Movie>(id);
         if (Movie != null)
         {
             db.Delete(Movie);
         }
     }
 }
Пример #15
0
 public int Delete(HistoryEntry entry)
 {
     Debug.Assert(TableExists(SqlTable.WuHistory));
     using (var connection = new SQLiteConnection(ConnectionString))
     {
         connection.Open();
         using (var database = new PetaPoco.Database(connection))
         {
             return(database.Delete(entry));
         }
     }
 }
Пример #16
0
        public ActionResult Delete(int id, string confirmButton)
        {
            try
            {
                var db = new PetaPoco.Database("MissNancy");
                db.Delete("tblClasses", "ClassKey", null, id);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
Пример #17
0
 public void CancelTicket(int id)
 {
     using (var db = new PetaPoco.Database(ConnectionString, providerName))
     {
         List <int> SeatIds = db.Fetch <int>("SELECT SeatId from Tickets where Id = @0", id);
         for (int i = 0; i < SeatIds.Count; i++)
         {
             var Seat = db.SingleOrDefault <Seat>(SeatIds[i]);
             Seat.Occupied = false;
             db.Update(Seat);
         }
         db.Delete <Ticket>(id);
     }
 }
Пример #18
0
 public void Delete(DBObject.Image image)
 {
     _database.Delete("tblImages", "id", image);
 }
Пример #19
0
 private static int Delete100Test(string connectionString)
 {
     var db = new PetaPoco.Database(connectionString, "System.Data.SqlClient");
     var homes = db.Query<Home>("SELECT * FROM home WHERE BuildYear=@0", 2015).ToList();
     int count = homes.Count();
     foreach (var home in homes)
     {
         if (home != null)
         {
             home.BuildYear = 2015;
             db.Delete("Home", "Id", home);
         }
     }
     return count;
 }
Пример #20
0
 public void Delete(T t)
 {
     db.Delete(t);
 }
Пример #21
0
 public void Delete(DBObject.ImagePath imagePath)
 {
     _database.Delete("tblImagesDatabase", "id", imagePath);
 }
Пример #22
0
        public WriteMonitor()
            : base("/write/monitor")
        {
            this.RequiresAuthentication();
            this.RequiresAnyClaim(new[] { "editMonitor", "admin" });

            // db reference
            var db = new PetaPoco.Database("LocalSQLite");

            // datatable functions

            Post["/dt/edit"] = pameters =>
            {
                // try\catch return  success\fail
                try
                {
                    Model.Monitor m = new Model.Monitor();
                    // get the previous verison of the monitor and then set up the monitor event handlers
                    // not doing it like this anymore
                    //m.PropertyChanged += new PropertyChangedEventHandler(App.Monitor.HandleActiveChangeEvent);
                    m = this.Bind();

                    log.InfoFormat("Updating monitor (ID: {0})", m.MonitorID.ToString());

                    // change the monitor state in the app layer/
                    if (Convert.ToBoolean(m.Active) != App.Monitor.IsActive(m))
                    {
                        App.Monitor.setState(m);
                    }

                    // TODO: get a previous version of the monitor and check if the interval has changed.
                    // Change the interval
                    if (m.Active == 1)
                    {
                        App.Monitor.ChangeInterval(m.MonitorID, m.RunInterval);
                    }

                    // persist the monitor, without the State column
                    db.Update(m, m.ColumnsToUpdateFromWeb);

                    return(Response.AsJson(new
                    {
                        success = true,
                        aaData = m
                    }));
                }
                catch (Exception ex)
                {
                    // Log error on the server - maybe should have ID in the URL so it can be part of the exception
                    log.WarnFormat("Error whilst editing monitor. Exception: {0}", ex.ToString());
                    // TODO: alert?
                    return(Response.AsJson(new
                    {
                        success = false,
                        message = ex.ToString()
                    }));
                }
            };

            Post["/dt/new"] = pameters =>
            {
                // try\catch return  success\fail
                Model.Monitor m = new Model.Monitor();

                log.InfoFormat("Adding new monitor (ID: {0})", m.MonitorID.ToString());

                try
                {
                    db.Insert(m);
                    // TODO: check if the monitor needs to start
                    return(Response.AsJson(new
                    {
                        success = true,
                        monitor = m
                    }));
                }
                catch (Exception ex)
                {
                    return(Response.AsJson(new
                    {
                        success = false,
                        message = ex.ToString()
                    }));
                }
            };

            Post["/dt/delete"] = parameter =>
            {
                try
                {
                    Model.Monitor m = new Model.Monitor();
                    m = this.Bind();

                    log.InfoFormat("Deleting monitor (ID: {0})", m.MonitorID.ToString());

                    db.Delete(m);

                    return(Response.AsJson(new
                    {
                        success = true
                    }));
                }
                catch (Exception ex)
                {
                    // Log error on the server - maybe should have ID in the URL so it can be part of the exception
                    log.WarnFormat("Error whilst deleting monitor. Exception: {0}", ex.ToString());
                    // TODO: alert?
                    return(Response.AsJson(new
                    {
                        success = false,
                        message = ex.ToString()
                    }));
                }
            };
        }
Пример #23
0
 public int Delete(HistoryEntry entry)
 {
    Debug.Assert(TableExists(SqlTable.WuHistory));
    using (var connection = new SQLiteConnection(ConnectionString))
    {
       connection.Open();
       using (var database = new PetaPoco.Database(connection))
       {
          return database.Delete(entry);
       }
    }
 }
Пример #24
0
        public int DeleteById(int id)
        {
            var db = new PetaPoco.Database("umbShow");

            return(db.Delete <Show>("WHERE idShow=@0", id));
        }
 public object DELETE(int id) {
     var db = new PetaPoco.Database("jlapc");
     db.Delete("Novedad", "NovedadID", null, id);
     JsonResult rta = new JsonResult() { Data = new { ok = true }, JsonRequestBehavior = JsonRequestBehavior.AllowGet };
     return rta.Data;
 }
Пример #26
0
 public void Delete(DBObject.Species species)
 {
     _database.Delete("tblFungi", "id", species);
 }
Пример #27
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                // Create a PetaPoco database object
                var db = new PetaPoco.Database("sqlite");

                // find the (presumably) most recently created foo
                int id = db.ExecuteScalar<int>("SELECT max(id) from foo");

                // Delete it
                db.Delete("foo", "Id", null, id);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message + Environment.NewLine + ex.StackTrace);
            }
            this.fooQuery1.Refresh();
        }