public string LoadHouseImage(Guid contextId, Guid ContextSubId, Enums.ContextSubType ContextSubTypeId, Enums.PhotoCategory PhotoCategoryId) { List <String> images = null; string imagePath = "~/Images/Sample/House.jpg"; try { List <Photo> PhotoList = SelectAllByContextSubTypeId(contextId, ContextSubId, ContextSubTypeId, PhotoCategoryId); if (PhotoList.Count > 0) { images = new List <string>(PhotoList.Count); foreach (Photo _List in PhotoList) { if (File.Exists(System.Web.HttpContext.Current.Server.MapPath(_List.FilePath))) { imagePath = _List.FilePath; } } } } catch (Exception ec) { } return(imagePath); }
public List <Photo> SelectAllByContextSubTypeId(Guid contextId, Guid ContextSubId, Enums.ContextSubType ContextSubTypeId, Enums.PhotoCategory PhotoCategoryId) { return(PhotoDAO.GetAllByFieldValue("ContextId", contextId, "ContextSubId", ContextSubId, ContextSubTypeId, PhotoCategoryId)); }
public static List <Photo> GetAllByFieldValue(string fieldName, Guid fieldValue, string fieldName2, Guid fieldValue2, Enums.ContextSubType ContextSubTypeId, Enums.PhotoCategory PhotoCategoryId) { List <Photo> returnEntityCollection = new List <Photo>(); Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING); DbCommand dbCommand = db.GetStoredProcCommand("usp_PhotoSelectAllBy" + fieldName2); db.AddInParameter(dbCommand, fieldName, DbType.Guid, fieldValue); db.AddInParameter(dbCommand, fieldName2, DbType.Guid, fieldValue2); db.AddInParameter(dbCommand, "ContextSubTypeId", DbType.Int32, (int)ContextSubTypeId); db.AddInParameter(dbCommand, "PhotoCategoryId", DbType.Int32, (int)PhotoCategoryId); using (IDataReader dataReader = db.ExecuteReader(dbCommand)) { while (dataReader.Read()) { Photo entity = new Photo(); Utility.Generic.AssignDataReaderToEntity(dataReader, entity); returnEntityCollection.Add(entity); } } return(returnEntityCollection); }