public static PostPhotoManager GetInstance(ApplicationDbContext context) { if (manager == null) { manager = new PostPhotoManager(context); } return(manager); }
// needs rework /*public List<PostPhoto> SavePhotos(List<HttpPostedFileBase> postPhotos, HttpServerUtilityBase server) * { * List<PostPhoto> postPhotosToReturn = new List<PostPhoto>(); * for (int i = 0; i < postPhotos.Count; i++) * { * var file = postPhotos[i]; * * if (file != null) * { * var postPhotoName = Path.GetFileName(file.FileName); * PostPhoto postPhoto = new PostPhoto() * { * PostPhotoName = postPhotoName, * PostPhotoExtension = Path.GetExtension(postPhotoName), * * * }; * postPhotosToReturn.Add(postPhoto); * var path = Path.Combine(server.MapPath("~/Content/Assets/Images/PostPhotos/"), postPhoto.Date.Ticks + postPhoto.PostPhotoName); * file.SaveAs(path); * } * } * return postPhotosToReturn; * } * * public void DeletePhotos(ICollection<PostPhoto> postPhotos, HttpServerUtilityBase server) * { * foreach (var item in postPhotos) * { * string savedPhotoName = server.MapPath("~/Content/Assets/Images/PostPhotos/" + item.Date.Ticks + item.PostPhotoName); * if (File.Exists(savedPhotoName)) * { * * File.Delete(savedPhotoName); * } * * } * }*/ public void Dispose() { manager = null; }