public ObservableCollection <PictureModel> CreatePictureModelList() { ObservableCollection <PictureModel> auxPictureModelList = new ObservableCollection <PictureModel>(); List <PictureModel> PictureList = new List <PictureModel>(); PictureList = _DataAccessLayer.ReturnAllPictureModels(); foreach (PictureModel pictureModel in PictureList) { IPTCModel auxIPTCModel = _DataAccessLayer.GetIPTCInfoByID(pictureModel.IPTC_ID); pictureModel.IPTC = auxIPTCModel; EXIFModel auxEXIFModel = _DataAccessLayer.GetEXIFInfoByID(pictureModel.EXIF_ID); pictureModel.EXIF = auxEXIFModel; PhotographerModel auxPhotographerModel = _DataAccessLayer.GetPhotographerByID(pictureModel.Photographer_ID); pictureModel.Photographer = auxPhotographerModel; ObservableCollection <string> auxTags = _DataAccessLayer.GetTagsByPictureID(pictureModel.ID); pictureModel.Tags = auxTags; auxPictureModelList.Add(pictureModel); } Console.Write("\n\n There are " + auxPictureModelList.Count + " pictures in the list"); return(auxPictureModelList); }
public void Save(IPTCModel iptc) { var output = $"Save IPTC model for picture with ID: {iptc.Pic_ID}"; if (iptc == null) { throw new ArgumentNullException(nameof(iptc)); } Console.WriteLine(output); try { Conn.Open(); PS.SaveIptc.Parameters["@Keywords"].Value = iptc.Keywords; PS.SaveIptc.Parameters["@ByLine"].Value = iptc.ByLine; PS.SaveIptc.Parameters["@CopyrightNotice"].Value = iptc.CopyrightNotice; PS.SaveIptc.Parameters["@Headline"].Value = iptc.Headline; PS.SaveIptc.Parameters["@Caption"].Value = iptc.Caption; PS.SaveIptc.Parameters["@FK_Pic_ID"].Value = iptc.Pic_ID; PS.SaveIptc.ExecuteNonQuery(); Conn.Close(); } catch (Exception e) { Console.WriteLine(e.Message); throw new Exception(output, e); } finally { Conn.Close(); } }
public void InsertAllIPTCData() { IPTCModel iptc; IPTCList.Clear(); if (PictureList.Count == 0) { this.InsertAllPictures(); } iptc = new IPTCModel(1, "amazingTitle", "Shrek", ""); IPTCList.Add(iptc); PictureList[0].IPTC_ID = 1; iptc = new IPTCModel(2, "anothertitle", "Flo", ""); IPTCList.Add(iptc); PictureList[1].IPTC_ID = 2; iptc = new IPTCModel(3, "CoolPicture", "Matschi", ""); IPTCList.Add(iptc); PictureList[2].IPTC_ID = 3; iptc = new IPTCModel(4, "subtleTitle", "Chrissy", ""); IPTCList.Add(iptc); PictureList[3].IPTC_ID = 4; iptc = new IPTCModel(5, "IAmBatman", "Batman", "I am Batman."); IPTCList.Add(iptc); PictureList[4].IPTC_ID = 5; iptc = new IPTCModel(6, "AwYissATitle", "Bob", ""); IPTCList.Add(iptc); PictureList[5].IPTC_ID = 6; }
public ObservableCollection <PictureModel> SearchAllPictures(string search) { var results = new ObservableCollection <PictureModel>(); var resultList = _DataAccessLayer.SearchForPictures(search); foreach (PictureModel pictureModel in resultList) { IPTCModel auxIPTCModel = _DataAccessLayer.GetIPTCInfoByID(pictureModel.IPTC_ID); pictureModel.IPTC = auxIPTCModel; EXIFModel auxEXIFModel = _DataAccessLayer.GetEXIFInfoByID(pictureModel.EXIF_ID); pictureModel.EXIF = auxEXIFModel; PhotographerModel auxPhotographerModel = _DataAccessLayer.GetPhotographerByID(pictureModel.Photographer_ID); pictureModel.Photographer = auxPhotographerModel; ObservableCollection <string> auxTags = _DataAccessLayer.GetTagsByPictureID(pictureModel.ID); pictureModel.Tags = auxTags; results.Add(pictureModel); } return(results); }
public IPTCViewModel(IPTCModel iptc) { Title = iptc.Title; Caption = iptc.Caption; CopyrightNotice = iptc.CopyrightNotice; Creator = iptc.Creator; Keywords = iptc.Keywords; }
public IPTCModel readIPTC() { IPTCModel iptc = new IPTCModel(); iptc.Title = "Best Image"; iptc.Caption = "An image"; iptc.CopyrightNotice = "to whom'st it belongs"; iptc.Creator = "the camera"; iptc.Keywords = "cats"; return(iptc); }
public void IPTCInfoByID() { MockDAL mock = new MockDAL(); mock.InsertAllPictures(); mock.InsertAllEXIFData(); mock.InsertAllIPTCData(); IPTCModel model = mock.GetIPTCInfoByID(2); Assert.That(model.Title, Is.EqualTo("anothertitle")); }
/// /// Constructor for existing Data /// public IPTCViewModel(IPTCModel iptc) { if (iptc != null) { License = iptc.License; PhotographerName = iptc.PhotographerName; Category = iptc.Category; IsEdited = iptc.IsEdited; KeyWords = iptc.KeyWords; Notes = iptc.Notes; CreationDate = iptc.CreationDate; } }
/// <summary> /// Extracts IPTC information from a picture. NOTE: You may simulate the action. /// </summary> /// <param name="filename"></param> /// <returns></returns> public IIPTCModel ExtractIPTC(string filename) { var iptcData = new IPTCModel(); IEnumerable <string> pathFiles = Directory.EnumerateFiles(GlobalInformation.Path); if (!pathFiles.Contains(Path.Combine(GlobalInformation.Path, filename))) { throw new FileNotFoundException(); } iptcData.ByLine = "ByLine"; iptcData.Caption = "caption"; iptcData.CopyrightNotice = "this is my shit - bro!"; iptcData.Headline = "I'm the Head"; iptcData.Keywords = "Blame on me"; return(iptcData); }
public IPTCModel GetIPTC(int ID) { IPTCModel iptc = new IPTCModel(); using (connection = new SqlConnection(connectionString)) using (SqlDataAdapter adapter = new SqlDataAdapter("SELECT * FROM Pictures WHERE Id = " + ID, connection)) { DataTable table = new DataTable(); adapter.Fill(table); iptc.City = (string)table.Rows[0][6]; iptc.Caption = (string)table.Rows[0][7]; iptc.Headline = (string)table.Rows[0][8]; return(iptc); } }
public void SaveIPTC(int id, IPTCModel iptc) { connection = new SqlConnection(connectionString); string sql = "update Pictures set Iptc_City = '" + iptc.City + "', " + "Iptc_Caption = '" + iptc.Caption + "', " + "Iptc_Headline = '" + iptc.Headline + "' " + "where Id = '" + id + "'"; using (connection) using (SqlDataAdapter adapter = new SqlDataAdapter()) { connection.Open(); adapter.UpdateCommand = new SqlCommand(sql, connection); adapter.UpdateCommand.ExecuteNonQuery(); } }
private void AddIPTC(IPTCModel iptc, int id) { SqlCommand cmd = new SqlCommand("Select Id from IPTC WHERE PictureId = @id; SELECT SCOPE_IDENTITY();", _connection); cmd.Parameters.AddWithValue("@id", id); OpenConnection(); int?exists = (int?)cmd.ExecuteScalar(); if (exists.HasValue) { cmd = new SqlCommand("UPDATE IPTC SET Title = @title, Description = @desc, Keywords = @keywords WHERE PictureId = @id", _connection); } else { cmd = new SqlCommand("INSERT INTO IPTC (PictureId, Title, Description, Keywords) VALUES (@id, @title, @desc, @keywords)", _connection); } cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@title", iptc.Title); cmd.Parameters.AddWithValue("@desc", iptc.Description); cmd.Parameters.AddWithValue("@keywords", iptc.Keywords); CmdExe(cmd); }
public IPTCModel getIPTCInfos() { IPTCModel im = new IPTCModel(); return(im); }
public IPTCViewModel(int ID) { iptc = bl.getIptc(ID); this.id = ID; }
public void SaveIPTC(int id, IPTCModel iptc) { throw new NotImplementedException(); }