コード例 #1
0
 public ActionResult AddLink(EventContentLink ecl)
 {
     // some model checking is done here just because we are exploiting structures above
     // and it means that we will get a null above when we don't want to allow that here
     if (ecl.link_location == null || ecl.link_location.Trim() == "")
     {
         ModelState.AddModelError("link_location", "Link Location is required");
     }
     string contentLocation = Url.Content("~/Content/");
     if (ecl.link_location != null &&
         (!SettingsData.Default.DisableLinkLocationCheck &&
         ecl.link_location.IndexOf(contentLocation) != 0))
     {
         ModelState.AddModelError("link_location",
                                  String.Format(
                                     "Links must start with {0} (files need to be in {0})",
                                     contentLocation));
     }
     if (ModelState.IsValid)
     {
         _repository.AddEventContentLink(ecl);
         _repository.Save();
         TempData["Message"] = "Link added";
         return RedirectToAction("Edit", new { id = ecl.event_id });
     }
     return View("AddLink", ecl);
 }
コード例 #2
0
 public ActionResult AddLink(int id)
 {
     Event ev = _repository.GetEventById(id);
     if (ev == null)
     {
         return View("EventNotFound");
     }
     var ecl = new EventContentLink
                 {
                     Event = ev
                 };
     return View("AddLink", ecl);
 }
コード例 #3
0
 public void DeleteEventContentLink(EventContentLink ecl)
 {
     _eventContentLinks.Remove(ecl);
 }
コード例 #4
0
 public void AddEventContentLink(EventContentLink ecl)
 {
     ecl.id = ++_eventContentLinkMaxId;
     _eventContentLinks.Add(ecl);
 }
コード例 #5
0
 public void AddEventContentLink(EventContentLink ecl)
 {
     _conferenceware.EventContentLinks.InsertOnSubmit(ecl);
 }
コード例 #6
0
 public void DeleteEventContentLink(EventContentLink ecl)
 {
     _conferenceware.EventContentLinks.DeleteOnSubmit(ecl);
 }
コード例 #7
0
 private string ProcessUpload(EventContentLink ecl)
 {
     HttpPostedFileBase hpf = Request.Files["link_location"];
     if (hpf == null || hpf.ContentLength == 0)
     {
         ModelState.AddModelError("link_location", "File required");
     }
     string dir = AppDomain.CurrentDomain.BaseDirectory + "\\Content\\" +
                  ecl.event_id + "\\";
     string filename = hpf.FileName;
     if (System.IO.File.Exists(dir + filename))
     {
         int i = 0;
         while (System.IO.File.Exists(dir + i + filename))
         {
             i++;
         }
         filename = i + filename;
     }
     try
     {
         if (!Directory.Exists(dir))
         {
             Directory.CreateDirectory(dir);
         }
         hpf.SaveAs(dir + filename);
     }
     catch
     {
         TempData["Message"] = "Unable to write file";
         ModelState.AddModelError("link_location", "File could not be saved");
     }
     return filename;
 }
コード例 #8
0
 public ActionResult UploadContent(EventContentLink ecl)
 {
     Event ev = _repository.GetEventById(ecl.event_id);
     if (ev == null)
     {
         return View("EventNotFound");
     }
     string filename = ProcessUpload(ecl);
     if (ModelState.IsValid)
     {
         // add link
         ecl.link_location = "/Content/" + ecl.event_id + "/" + filename;
         _repository.AddEventContentLink(ecl);
         _repository.Save();
         TempData["Message"] = "Content added";
         return RedirectToAction("Edit", new { id = ecl.event_id });
     }
     ecl.Event = _repository.GetEventById(ecl.event_id);
     return View("UploadContent", ecl);
 }
コード例 #9
0
 partial void DeleteEventContentLink(EventContentLink instance);
コード例 #10
0
 partial void UpdateEventContentLink(EventContentLink instance);
コード例 #11
0
 partial void InsertEventContentLink(EventContentLink instance);
コード例 #12
0
		private void detach_EventContentLinks(EventContentLink entity)
		{
			this.SendPropertyChanging();
			entity.Event = null;
		}