public ActionResult Detail(long id) { ProductDAO db = new ProductDAO(); var model = db.Detail(id); var product = Session[ProductSession]; if (product != null) { var list = (List <ProductModel>)product; if (list.Exists(x => x.ID == id) == false) { list.Add(model); } Session[ProductSession] = list; } else { var list = new List <ProductModel>(); list.Add(model); Session[ProductSession] = list; } List <string> ListImages = new ImageDAO().GetAllImage(id); var ListDetail = new ProductDetailDao().GetAllProductDetail(id); ViewBag.ListDetail = ListDetail; ViewBag.ListImages = ListImages; return(View(model)); }
public ActionResult ApproveApp(int id) { try { if (Session["ModId"] != null) { UserDAO udao = new UserDAO(); User u = udao.SearchById(int.Parse(Session["Id"].ToString())); ImageDAO idao = new ImageDAO(); ApplicationDAO dao = new ApplicationDAO(); TypeAppDAO tdao = new TypeAppDAO(); GenreDAO gdao = new GenreDAO(); PegiDAO pdao = new PegiDAO(); ApplicationGenreDAO agdao = new ApplicationGenreDAO(); ViewBag.Types = tdao.List(); ViewBag.Pegis = pdao.List(); ViewBag.AppGens = agdao.ListByApplication(id); ViewBag.Genres = gdao.List(); ViewBag.User = u; ViewBag.App = dao.SearchById(id); ViewBag.Img = idao.SearchAppImages(id); return(View()); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult Edit(int ID) { var productDisplay = new ProductDisplay(); var product = new ProductDAO().GetByID(ID); var imageProduct = new ImageDAO().GetMainImgByProductID(ID); productDisplay.Product = product; productDisplay.ListImage = new List <ImageProduct>(); productDisplay.ListImage.Add(imageProduct); ViewBag.srcImgEdit = "~/Images/plus.png"; if (TempData["pathImageEdit"] != null) { Session["avatarUploadEdit"] = TempData["pathImageEdit"]; ViewBag.srcImgEdit = TempData["pathImageEdit"]; } else if (!string.IsNullOrEmpty(imageProduct.Src)) { ViewBag.srcImgEdit = imageProduct.Src; Session["avatarUploadEdit"] = imageProduct.Src; } else { ViewBag.srcImgEdit = "~/Images/plus.png"; } return(View(productDisplay)); }
public static string GetImage(int id) { using (var dao = new ImageDAO()) { return(dao.GetImage(id)); } }
private void button3_Click(object sender, EventArgs e) { ImageDAO imageDAO = new ImageDAO(); CodeDAO codeDAO = new CodeDAO(); SourceControlDAO sourceControl = new SourceControlDAO(); BugDAO bugDAO = new BugDAO(); DialogResult dr = MessageBox.Show("Are you sure want to delete this bug?", "Are you sure", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information); if (dr == DialogResult.Yes) { try { codeDAO.Delete(bugId); imageDAO.Delete(bugId); bugDAO.Delete(bugId); sourceControl.Delete(bugId); MessageBox.Show("Deleted"); this.Dispose(); new Bugs().Show(); } catch (Exception ex) { Console.WriteLine(ex.Message); } } }
public ActionResult Image(string id) { var session = (UserLogin)Session[CommonConstants.USER_SESSION]; var model = new ImageDAO().GetByFileName(session.UserID, id); return(View(model)); }
public ActionResult Product(int id) { try { ApplicationDAO dao = new ApplicationDAO(); DeveloperDAO ddao = new DeveloperDAO(); ImageDAO idao = new ImageDAO(); UserDAO udao = new UserDAO(); SellItemDAO sidao = new SellItemDAO(); Application app = dao.SearchById(id); Developer dev = ddao.SearchById(app.DeveloperId); CartDAO cdao = new CartDAO(); PegiDAO pdao = new PegiDAO(); ViewBag.SellItem = false; if (Session["Id"] != null) { ViewBag.Cart = cdao.SearchCartUser(int.Parse(Session["Id"].ToString())); ViewBag.SellItem = sidao.SearchUserApp(int.Parse(Session["Id"].ToString()), id); WishlistDAO wdao = new WishlistDAO(); ViewBag.IsInWish = wdao.IsInWishList(int.Parse(Session["Id"].ToString()), id); } ViewBag.App = app; ViewBag.Dev = dev; ViewBag.Pegi = pdao.SearchById(app.PegiId); ViewBag.DevUser = udao.SearchByDev(dev.Id); ViewBag.Img = idao.SearchAppImages(id); ViewBag.Similar = dao.ListLast10(); return(View()); } catch { return(RedirectToAction("../Home/Index")); } }
public ActionResult Images() { var session = (UserLogin)Session[CommonConstants.USER_SESSION]; var model = new ImageDAO().MyUpload(session.UserID); return(View(model)); }
public ActionResult Buy(int id) { ProductDAO productDAO = new ProductDAO(); ImageDAO imageDAO = new ImageDAO(); if (Session["cart"] == null) { List <Cart> cart = new List <Cart>(); cart.Add(new Cart { product = productDAO.GetById(id), quantity = 1 }); Session["cart"] = cart; } else { List <Cart> cart = (List <Cart>)Session["cart"]; int index = isExist(id); if (index != -1) { cart[index].quantity++; } else { cart.Add(new Cart { product = productDAO.GetById(id), quantity = 1 }); } Session["cart"] = cart; } return(RedirectToAction("Index")); }
public void UploadImage_ShouldUploadLink() { var dao = new ImageDAO(); var result = dao.Upload("https://i.ytimg.com/vi/AZ2ZPmEfjvU/maxresdefault.jpg"); Assert.IsTrue(result.Success); }
public ShoesManageController(SneakerStoreContext context, IHostingEnvironment env) { this.context = context; this._env = env; shoesDao = new ShoesDAO(context); shoesColorDao = new ShoesColorDAO(context); shoesSizeDao = new ShoesSizeDAO(context); priceDao = new PriceDAO(context); imageDao = new ImageDAO(context); }
private static void IsImageDaoEqual(ImageDAO objectA, ImageDAO objectB) { Assert.AreEqual(objectA.Id, objectB.Id); Assert.AreEqual(objectA.Base64, objectB.Base64); for (var i = 0; i < (objectA.Observations).Count; i++) { IsObservationDaoEqual(objectA.Observations[i], objectB.Observations[i]); } }
public void SendComment(Guid?From, Guid?Article, string type) { Guid?Id = null; if (type == "Article") { var dao = new ArticleDAO(); var article = dao.GetById(Article); if (article.ACCOUNT_Id == From) { var To = new UniversityMagazineDBContext().ACCOUNTs.Where(x => x.ROLEGROUP.ROLEGROUP_Code == "MARKETINGCOORDINATOR" && x.FACULTY_Id == article.FACULTY_Id).FirstOrDefault().ACCOUNT_Id; if (type == "Article") { Id = new CommentArticleDAO().CreateNotificationComment(From, To, "/Upload/Articles/Article/" + article.ARTICLE_FileName, type); } LoadNotification(To); } else { if (type == "Article") { Id = new CommentArticleDAO().CreateNotificationComment(From, article.ACCOUNT_Id, "/MyUpload/File/" + article.ARTICLE_FileName, type); } LoadNotification(article.ACCOUNT_Id); } } else if (type == "Image") { var dao = new ImageDAO(); var image = dao.GetById(Article); if (image.ACCOUNT_Id == From) { var To = new UniversityMagazineDBContext().ACCOUNTs.Where(x => x.ROLEGROUP.ROLEGROUP_Code == "MARKETINGCOORDINATOR" && x.FACULTY_Id == image.FACULTY_Id).FirstOrDefault().ACCOUNT_Id; if (type == "Image") { Id = new CommentArticleDAO().CreateNotificationComment(From, To, "/Upload/Images/Image/" + image.IMAGE_FileName, type); } LoadNotification(To); } else { if (type == "Image") { Id = new CommentArticleDAO().CreateNotificationComment(From, image.ACCOUNT_Id, "/MyUpload/Image/" + image.IMAGE_FileName, type); } LoadNotification(image.ACCOUNT_Id); } } if (Id != null) { LoadDetailNotification(Id); } }
public FileContentResult image(int id) { using (var dao = new ImageDAO()) { string path = HostingEnvironment.MapPath(dao.GetImage(id)); if (System.IO.File.Exists(path)) { return(File(System.IO.File.ReadAllBytes(path), "image/png")); } return(null); } }
public ActionResult UploadImage(IMAGE iMAGES, HttpPostedFileBase image) { var session = (UserLogin)Session[CommonConstants.USER_SESSION]; var dao = new AccountDAO(); var user = dao.GetById(session.UserID); Guid id = Guid.NewGuid(); iMAGES.IMAGE_Id = id; iMAGES.ACCOUNT_Id = session.UserID; iMAGES.FACULTY_Id = user.FACULTY_Id; if (image != null) { string fileName = new ImageDAO().GetCode(new StringHelper().RemoveUnicode(user.ACCOUNT_Name)); string extension = Path.GetExtension(image.FileName); iMAGES.IMAGE_FileName = fileName; fileName += extension; string Url = "/Images/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + user.FACULTY.FACULTY_Code + "/" + user.ACCOUNT_Username + "/" + fileName; fileName = Path.Combine(Server.MapPath("~/Images/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + user.FACULTY.FACULTY_Code + "/" + user.ACCOUNT_Username + "/"), fileName); if (!Directory.Exists(Server.MapPath("~/Images/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + user.FACULTY.FACULTY_Code + "/" + user.ACCOUNT_Username + "/"))) { Directory.CreateDirectory(Server.MapPath("~/Images/" + DateTime.Now.ToString("yyyy") + "/" + DateTime.Now.ToString("MM") + "/" + user.FACULTY.FACULTY_Code + "/" + user.ACCOUNT_Username + "/")); } iMAGES.IMAGE_FileUpload = Url; iMAGES.IMAGE_Type = extension.Replace(".", ""); iMAGES.IMAGE_Size = image.ContentLength; image.SaveAs(fileName); } if (new ImageDAO().Create(iMAGES)) { try { string content = System.IO.File.ReadAllText(Server.MapPath("~/Views/templates/UploadImage.html")); content = content.Replace("{{student}}", user.ACCOUNT_Username); content = content.Replace("{{domain}}", Request.Url.Host); content = content.Replace("{{image}}", iMAGES.IMAGE_FileName); content = content.Replace("{{username}}", dao.GetAccountCoordinator(user.FACULTY_Id).ACCOUNT_Username); new MailHelper().SendMail(dao.GetAccountCoordinator(user.FACULTY_Id).ACCOUNT_Email, "University Magazine", content, "Student upload file"); } catch (Exception) { SetAlert("Email sending failed!", "warning"); } SetAlert("Added successfully!", "success"); } else { SetAlert("Add failed!", "warning"); } return(RedirectToAction("UploadImage")); }
public ActionResult Delete(int ID) { var productDisplay = new ProductDisplay(); var product = new ProductDAO().GetByID(ID); var imageProduct = new ImageDAO().GetMainImgByProductID(ID); productDisplay.Product = product; productDisplay.ListImage = new List <ImageProduct>(); productDisplay.ListImage.Add(imageProduct); var result = new ProductDisplayDAO().Delete(productDisplay); return(View()); }
public async Task <bool> Create(Image Image) { ImageDAO ImageDAO = new ImageDAO(); ImageDAO.Id = Image.Id; ImageDAO.Name = Image.Name; ImageDAO.Url = Image.Url; ImageDAO.CreatedAt = StaticParams.DateTimeNow; ImageDAO.UpdatedAt = StaticParams.DateTimeNow; await DataContext.BulkMergeAsync <ImageDAO>(new List <ImageDAO> { ImageDAO }); return(true); }
public ActionResult Remove(int id) { try { ApplicationDAO dao = new ApplicationDAO(); ImageDAO idao = new ImageDAO(); Application a = dao.SearchById(id); if (Session["ModId"] != null || int.Parse(Session["DevId"].ToString()) == a.DeveloperId) { try { IList <Image> imgs = idao.SearchAppImages(a.Id); foreach (var i in imgs) { string p = i.Url; p = p.Replace("../../..", "../.."); string fullPath = Request.MapPath(p); idao.Remove(i); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } } } catch { } try { string pa = a.Archive; pa = pa.Replace("../../..", "../.."); string fullPathArch = Request.MapPath(pa); if (System.IO.File.Exists(fullPathArch)) { System.IO.File.Delete(fullPathArch); } } catch { } dao.Remove(a); return(RedirectToAction("Summary", "Developer")); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult EditPhoto(int id, int PhotoId, HttpPostedFileBase img) { try { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(id); if (Session["ModId"] != null || int.Parse(Session["DevId"].ToString()) == a.DeveloperId) { ImageDAO idao = new ImageDAO(); Image i = idao.SearchById(PhotoId); bool b = false; if (a.ImageUrl == i.Url) { b = true; } //Delete Photo in Server string p = i.Url; p = p.Replace("../../..", ".."); string fullPath = Request.MapPath(p); idao.Remove(i); if (System.IO.File.Exists(fullPath)) { System.IO.File.Delete(fullPath); } //Upload string filePath = Guid.NewGuid() + Path.GetExtension(img.FileName); img.SaveAs(Path.Combine(Server.MapPath("~/media/app"), filePath)); Image im = new Image(); im.Url = "../../../media/app/" + filePath; im.UserId = int.Parse(Session["Id"].ToString()); im.ApplicationId = a.Id; idao.Add(im); if (b) { a.ImageUrl = im.Url; dao.Update(); } return(RedirectToAction("EditApp", "Application", new { id = a.Id })); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult TurntoMain(int id, int AppId) { try { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(AppId); if (Session["ModId"] != null || int.Parse(Session["DevId"].ToString()) == a.DeveloperId) { ImageDAO idao = new ImageDAO(); Image i = idao.SearchById(id); a.ImageUrl = i.Url; dao.Update(); return(RedirectToAction("EditApp", "Application", new { id = a.Id })); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public ActionResult EditApp(int id) { try { ApplicationDAO dao = new ApplicationDAO(); Application App = dao.SearchById(id); UserDAO udao = new UserDAO(); TypeAppDAO tdao = new TypeAppDAO(); PegiDAO pdao = new PegiDAO(); GenreDAO gdao = new GenreDAO(); ApplicationGenreDAO agdao = new ApplicationGenreDAO(); if (Session["ModId"] != null || App.DeveloperId == int.Parse(Session["DevId"].ToString())) { ViewBag.User = udao.SearchById(int.Parse(Session["Id"].ToString())); ImageDAO idao = new ImageDAO(); ViewBag.Imgs = idao.SearchAppImages(App.Id); ViewBag.App = App; ViewBag.Types = tdao.List(); ViewBag.Pegis = pdao.List(); IList <Genre> genres = gdao.ListId(); IList <ApplicationGenre> agens = agdao.ListByApplication(id); foreach (var ag in agens) { foreach (var g in genres) { if (ag.GenreId == g.Id) { g.IsChecked = true; } } } ViewBag.Genres = genres; return(View()); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
public object HotelImageUpload() { HttpRequestMessage request = this.Request; if (!request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } var Images = new List <ImageViewModel>(); var Current = HttpContext.Current; var key = Current.Request["key"]; if (Current.Session[key] != null) { Images = (List <ImageViewModel>)Current.Session[key]; //Images = Images.Select(o => { o.Hotel = null; return o; }).ToList(); } var ImgDao = new ImageDAO(); for (int i = 0; i < HttpContext.Current.Request.Files.Count; i++) { var file = HttpContext.Current.Request.Files[i]; var subName = Path.GetExtension(file.FileName); //var fileName = Guid.NewGuid().GetHashCode().ToString("x"); var fileName = file.FileName; var image = ImgDao.FileToByte(file); Images.Add(new ImageViewModel { Image = image, Name = fileName, Extension = subName }); } var Message = "完成上傳"; Current.Session[key] = Images; var data = JsonConvert.SerializeObject(Images); return(Json(new { data = data, message = Message })); }
/// <summary> /// Adds base64 representation of SKImage and Observations to DB, /// or updates an already existing image within the DB /// </summary> /// <see cref="ImageDAO"/> and <see cref="ObservationDAO"/> public static ImageDAO InsertOrUpdate(ImageEntry imageEntry) { if (imageEntry == null) { throw new ArgumentNullException(); } using (var db = CreateOrGetLiteDBConnection()) { var img = imageEntry.Image; var name = imageEntry.Name; var creationTime = imageEntry.CreationTime ?? DateTime.UtcNow; var observations = imageEntry.Observations; var imageCollection = db.GetCollection <ImageDAO>(SharedConstants.ImageCollectionName); var observationCollection = db.GetCollection <ObservationDAO>(SharedConstants.ObservationCollectionName); var imageDao = new ImageDAO(img, name, creationTime); var observationDaos = new List <ObservationDAO>(); if (imageEntry.Id == null) { AddObservationsToImgDao(observations, imageDao, observationDaos); imageCollection.Insert(imageDao); observationCollection.Insert(observationDaos); } else { imageDao.Id = (int)imageEntry.Id; AddObservationsToImgDao(observations, imageDao, observationDaos); imageCollection.Update(imageDao); observationCollection.Delete(x => x.Image.Id == imageEntry.Id); observationCollection.Insert(observationDaos); } return(imageDao); } }
public ActionResult EditValues(string id) { try { SettingGroup SettingGroup = SettingGroupDAO.LoadSettingGroupById(id); List <string> StaticPropertyKeys = (from e in SettingGroup.SettingsList.AsQueryable() where DataEntryTypeProperty.DataTypesRequireProperties.Contains(e.EntryType) && !string.IsNullOrWhiteSpace(e.DataEntryStaticPropertyKey) select e.DataEntryStaticPropertyKey).ToList(); ViewBag.SettingGroup = SettingGroup; ViewBag.StaticPropertyList = StaticPropertyKeys != null && StaticPropertyKeys.Count > 0 ?StaticPropertyDAO.LoadByMultipleKeyNames(StaticPropertyKeys) : new List <StaticProperty>(); ViewBag.ImageList = ImageDAO.LoadAll(); } catch (Exception e) { CompanyCommons.Logging.WriteLog("ChimeraWebsite.Areas.Admin.Controllers.SettingsController.EditValues() " + e.Message); } return(View()); }
private (ImageDAO, string) GenerateJsonsExamples() { var observations = new List <Observation>() { new Observation(_manager.GetOrCreate(0, "Car"), 0.5, new SKRect(0.1f, 0.2f, 0.7f, 0.8f)), new Observation(_manager.GetOrCreate(1, "Bat Mobile"), 0.7, new SKRect(0.1f, 0.2f, 0.7f, 0.8f)), }; const string name = "Image.jpg"; var creationTime = DateTime.UtcNow; var testImg = GraphicUtils.GetImageByDimensions(SharedConstants.DefaultChipWidth, SharedConstants.DefaultChipHeight); var imageDao = new ImageDAO(testImg, name, creationTime); foreach (var ob in observations) { imageDao.Add(new ObservationDAO(imageDao, ob)); } return(imageDao, JSONService.ConvertToJson(imageDao)); }
public ActionResult NewPhoto(int id, HttpPostedFileBase img) { try { ApplicationDAO dao = new ApplicationDAO(); Application a = dao.SearchById(id); if (Session["ModId"] != null || int.Parse(Session["DevId"].ToString()) == a.DeveloperId) { ImageDAO idao = new ImageDAO(); string filePath = Guid.NewGuid() + Path.GetExtension(img.FileName); img.SaveAs(Path.Combine(Server.MapPath("~/media/app"), filePath)); Image im = new Image(); im.Url = "../../../media/app/" + filePath; im.UserId = int.Parse(Session["Id"].ToString()); im.ApplicationId = a.Id; idao.Add(im); return(RedirectToAction("EditApp", "Application", new { id = a.Id })); } return(RedirectToAction("Index", "Home")); } catch { return(RedirectToAction("Index", "Home")); } }
private void btnUpdate_Click(object sender, EventArgs e) { //bug Bug bug = new Bug { BugId = bugId, ProjectName = label1.Text, ClassName = textBox2.Text, MethodName = textBox3.Text, StartLine = Convert.ToInt16(textBox4.Text), EndLine = Convert.ToInt16(textBox5.Text), ProgrammerId = Login.userId, Status = "0" }; try { BugDAO bugDao = new BugDAO(); bugDao.Update(bug); } catch (Exception ex) { Console.WriteLine(ex.Message); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //image if (!string.IsNullOrEmpty(ImageName)) { string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\code_image\"; Bug_Tracker.Model.Image image = new Bug_Tracker.Model.Image { ImageId = imageId, ImagePath = "code_image", ImageName = ImageName, BugId = bug.BugId }; try { ImageDAO codeDao = new ImageDAO(); codeDao.Update(image); File.Delete("code_image/" + currentImageName); File.Copy(imageName, appPath + ImageName); } catch (Exception ex) { Console.WriteLine(ex.Message); } } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////code string c = fastColoredTextBox1.Text; //Code code = new Code //{ // CodeId = codeId, // CodeFilePath = "code", // CodeFileName = codeFileName, // ProgrammingLanguage = programminLanguage, // BugId = bug.BugId //}; try { string path = @"code/" + codeFileName + ".txt"; using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(c); } } catch (Exception ex) { Console.WriteLine(ex.Message); } MessageBox.Show("Updated"); }
public static Image ToEntity(this ImageDAO dao) => Image.Create(dao.Id, dao.Extension, dao.Name, dao.Description, dao.Tags, dao.Created);
private void button1_Click(object sender, EventArgs e) { //bug BugViewModel bug = new BugViewModel { ProjectName = textBox1.Text, ClassName = textBox2.Text, MethodName = textBox3.Text, StartLine = Convert.ToInt16(textBox4.Text), EndLine = Convert.ToInt16(textBox5.Text), ProgrammerId = Login.userId }; try { BugDAO bugDao = new BugDAO(); bugDao.Insert(bug); } catch (Exception ex) { Console.WriteLine(ex.Message); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //image string appPath = Path.GetDirectoryName(Application.ExecutablePath) + @"\code_image\"; Bug_Tracker.Model.PictureViewModel image = new Bug_Tracker.Model.PictureViewModel { ImagePath = "code_image", ImageName = imageName, BugId = bug.BugId }; try { ImageDAO codeDao = new ImageDAO(); codeDao.Insert(image); File.Copy(imageName, appPath + ImageName); } catch (Exception ex) { Console.WriteLine(ex.Message); } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////code string c = fastColoredTextBox1.Text; string codeFileName = DateTime.Now.Second.ToString(); CodeViewModel code = new CodeViewModel { CodeFilePath = "code", CodeFileName = codeFileName, ProgrammingLanguage = programminLanguage, BugId = bug.BugId }; try { CodeDAO codeDao = new CodeDAO(); codeDao.Insert(code); string path = "code/" + codeFileName + ".txt"; if (!File.Exists(path)) { // Create a file to write to. using (StreamWriter sw = File.CreateText(path)) { sw.WriteLine(c); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } //Bug bug = new Bug { BugId = } }
private static void AddObservationsToImgDao(IEnumerable <Observation> observations, ImageDAO imageDao, ICollection <ObservationDAO> observationDaos) { foreach (var obs in observations) { var observationDao = new ObservationDAO(imageDao, obs); imageDao.Add(observationDao); observationDaos.Add(observationDao); } }