/// <summary>
        /// Veritabanına bir fotoğraf bilgisi kaydeder.
        /// </summary>
        /// <param name="shipUrl"></param>
        /// <returns></returns>
        public void AddShipUrl(ShipUrl shipUrl)
        {
            string query = "insert into photos (ship_id,image_url,preview) values (@ship_id,@image_url,@preview)";

            MySqlCommand cmd = new MySqlCommand(query, con);
            cmd.Parameters.AddWithValue("@ship_id",shipUrl.refId);
            cmd.Parameters.AddWithValue("@image_url",shipUrl.imageUrl);
            cmd.Parameters.AddWithValue("@preview", shipUrl.preview);

            Open();
            cmd.ExecuteNonQuery();
            Close();
        }
        public bool UpdateUploadShip(string ref_id, int ship_id, string description, string time, HttpPostedFileBase[] files, string choice)
        {
            string savingPath = Server.MapPath("~/Content/images/");
            System.IO.Directory.CreateDirectory(savingPath);

            Ship ship = new Ship();
            ship.refId = ref_id;
            ship.shipId = ship_id;
            ship.time = Convert.ToDateTime(time + ",00:00:00").Date;
            ship.description = description;
            ship.createdBy = User.Identity.Name;
            ship.createdPc = Request.UserHostName;
            ship.createdDatetime = DateTime.Now;

            //System.IO.Directory.CreateDirectory(Server.MapPath("~/Content/images"));
            ShipUrlData shipUrlData = ShipUrlData.GetShipUrlData();
            ShipData shipData = ShipData.GetShipData();

            ImageResize resizer = new ImageResize();
            FileMethods filer = new FileMethods();

            System.Drawing.Image photo;
            System.Drawing.Image preview;
            if (choice == "upload")
            {
                shipData.AddGemi(ship);
            }

            else if (choice == "update")
            {
                shipData.UpdateShip(ship);
            }

            foreach (HttpPostedFileBase file in files)
            {
                if (file == null) { continue; }
                if (shipUrlData.CheckDuplicateUrl(ref_id, file.FileName, Server.MapPath("~/Content/images/")))
                {
                    if (filer.CompareSizeOfFile(file, Server.MapPath("~/Content/images/" + ref_id + "_" + file.FileName)))
                    {
                        continue;
                    }
                }
                ShipUrl shipUrl = new ShipUrl();

                photo = filer.FileToImage(file);
                preview = resizer.Resize(photo, 320, 240);
                byte[] previewByte = filer.ImageToBytes(preview);

                shipUrl.refId = ref_id;
                shipUrl.preview = previewByte;

                string filename = savingPath + ref_id + "_" + file.FileName;

                /*if (filer.FileExists("", filename))
                {
                    while (filer.FileExists("", filename))
                    {
                        filename = filer.renameFile("", filename);
                    }
                }*/ //başına ref_id eklendiğinden kullanımına gerek kalmadı

                filer.SaveFile(photo, "", filename); //filename'e zaten dosya adından öncesi eklendi
                shipUrl.imageUrl = filename;

                shipUrlData.AddShipUrl(shipUrl);
                photo.Dispose();
                preview.Dispose();
            }

            return true;
        }
        /// <summary>
        /// Bir referans ID'si adına eklenmiş fotoğrafların bilgilerini liste olarak döndürür.
        /// </summary>
        /// <param name="refId"></param>
        /// <returns>ShipUrl sınıfından nesnelerin listesini döndürür.</returns>
        public List<ShipUrl> GetPhotos(string refId)
        {
            List<ShipUrl> urlList = new List<ShipUrl>();

            string query = "select id,image_url,preview from photos where ship_id = @ship_id";
            MySqlCommand cmd = new MySqlCommand(query, con);
            cmd.Parameters.AddWithValue("@ship_id", refId);

            Open();
            MySqlDataReader reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                ShipUrl shipUrl = new ShipUrl();
                shipUrl.refId = refId;
                shipUrl.id = Convert.ToInt32(reader["id"]);
                shipUrl.preview = (byte[])reader["preview"];
                shipUrl.imageUrl = Convert.ToString(reader["image_url"]);

                urlList.Add(shipUrl);
            }
            Close();

            return urlList;
        }