コード例 #1
0
 public void InsertOrUpdate(GalleryImage galleryimage)
 {
     if (galleryimage.ID == default(int)) {
         // New entity
         context.GalleryImage.Add(galleryimage);
     } else {
         // Existing entity
         context.GalleryImage.Attach(galleryimage);
         context.Entry(galleryimage).State = EntityState.Modified;
     }
 }
コード例 #2
0
        public ActionResult Create(GalleryImage galleryimage, HttpPostedFileBase file)
        {
            // TODO UserID muss aus Session kommen

            //galleryimage.CreatedOn = DateTime.UtcNow;
            //galleryimage.UserID = 1;

            //if (ModelState.IsValid) {
            //    galleryimageRepository.InsertOrUpdate(galleryimage);
            //    galleryimageRepository.Save();
            //    return RedirectToAction("Index");
            //} else {
                return View();
            //}
        }
コード例 #3
0
        public void Upload(HttpPostedFileBase FileData)
        {
            try {

                string path = UserContext.GetCurrent().ID + @"\" + "Gallery" + @"\";

                FileHelper.WriteFile(HttpContext.Server.MapPath("~") + ConfigurationManager.AppSettings["UserContentBasePath"] + @"\" + path, FileData.FileName, FileData.InputStream);

                GalleryImage galleryimage = new GalleryImage();
                galleryimage.CreatedOn = DateTime.UtcNow;
                galleryimage.ID = default(int);
                galleryimage.NumberOfViews = 0;
                galleryimage.Url = path + FileData.FileName;
                galleryimage.UserID = UserContext.GetCurrent().ID;

                galleryimageRepository.InsertOrUpdate(galleryimage);
                galleryimageRepository.Save();
            } catch (Exception e) {
                throw e;
            }
        }
コード例 #4
0
 public ActionResult Edit(GalleryImage galleryimage)
 {
     if (ModelState.IsValid) {
         galleryimageRepository.InsertOrUpdate(galleryimage);
         galleryimageRepository.Save();
         return RedirectToAction("Index");
     } else {
         ViewBag.PossibleUser = userRepository.All;
         return View();
     }
 }