private string GetPhotoPath(DatabaseModel.Photos a_Photo)
        {
            string mapPath = db.Maps.Where(m => m.m_MapId == a_Photo.m_MapId).Select(m => m.m_MapLocation).ToString();

            mapPath += ("/" + a_Photo.p_PhotoName);
            return(mapPath);
        }
 private void Delete(DatabaseModel.Maps a_Map, DatabaseModel.Photos a_Photo)
 {
     if (a_Map != null)
     {
         db.Maps.DeleteOnSubmit(a_Map);
     }
     if (a_Photo != null)
     {
         db.Photos.DeleteOnSubmit(a_Photo);
     }
 }
 private void Update(DatabaseModel.Maps a_Map, DatabaseModel.Photos a_Photo)
 {
     if (a_Photo != null)
     {
         int oldID              = a_Photo.p_PhotoID;
         var oldPhoto           = db.Photos.Where(p => p.p_PhotoID == oldID).FirstOrDefault();
         DatabaseModel.Maps map = db.Maps.Where(m => m.m_MapId == a_Photo.m_MapId).FirstOrDefault();
         oldPhoto = a_Photo;
     }
     if (a_Map != null)
     {
         int oldID  = a_Map.m_MapId;
         var oldMap = db.Maps.Where(m => m.m_MapId == oldID).FirstOrDefault();
         oldMap = a_Map;
     }
 }
 private void Create(DatabaseModel.Maps a_Map, DatabaseModel.Photos a_Photo)
 {
     if (a_Photo != null)
     {
         db.Photos.InsertOnSubmit(a_Photo);
     }
     if (a_Map != null)
     {
         if (db != null)
         {
             if (db.Maps != null)
             {
                 db.Maps.InsertOnSubmit(a_Map);
             }
         }
     }
 }
        public object Read(Reads a_ReadType, DatabaseModel.Maps a_Map, DatabaseModel.Photos a_Photo)
        {
            switch (a_ReadType)
            {
            case Reads.FULLPHOTOPATH:
                return(GetPhotoPath(a_Photo));

            case Reads.ALLPHOTOSFROMMAP:
                return(GetAllPhotosFromMap(a_Map));

            case Reads.ALLPHOTOS:
                return(GetAllPhotos());

            case Reads.DATACONTEXT:
            default:
                return(null);
            }
        }
        /// <summary>
        /// Basic database interactions: 0 = create, 1 = edit, 2 = delete
        /// </summary>
        /// <param name="a_Interaction"></param>
        /// <param name="a_Map"></param>
        /// <param name="a_Photo"></param>
        public void Interact(Methods a_Interaction, DatabaseModel.Maps a_Map, DatabaseModel.Photos a_Photo)
        {
            switch (a_Interaction)
            {
            case Methods.CREATE:
                Create(a_Map, a_Photo);
                break;

            case Methods.DELETE:
                Delete(a_Map, a_Photo);
                break;

            case Methods.UPDATE:
                Update(a_Map, a_Photo);
                break;

            default:
                break;
            }
            UpdateDB();
        }