public ActionResult SiteDetails(long id) { Collection collection = CollectionRepository.First(c => c.Site.ID == id, c => c.Site, c => c.CoverPhoto); Phocalstream_Shared.Data.Model.View.SiteDetails details = PhotoRepository.GetSiteDetails(collection.Site); details.LastPhotoURL = string.Format("{0}://{1}:{2}/api/photo/auto/{3}", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, collection.CoverPhoto == null ? details.LastPhotoID : collection.CoverPhoto.ID); return(PartialView("_SiteDetails", details)); }
public SiteDetails GetSiteDetails(CameraSite site) { SiteDetails details = new SiteDetails(); details.SiteName = site.Name; details.SiteID = site.ID; using (SqlConnection conn = new SqlConnection(_connectionString)) { conn.Open(); using (SqlCommand command = new SqlCommand("select min(Captured), max(Captured), count(*), max(ID) from Photos where Site_ID = @siteID", conn)) { command.Parameters.AddWithValue("@siteID", site.ID); using (SqlDataReader reader = command.ExecuteReader()) { if (reader.Read()) { details.First = reader.GetDateTime(0); details.Last = reader.GetDateTime(1); details.PhotoCount = reader.GetInt32(2); details.LastPhotoID = reader.GetInt64(3); } } } } return details; }