Esempio n. 1
0
 public void IncrementDownloads(int id)
 {
     using (vwarEntities entities = new vwarEntities(_ConnectionString))
     {
         var co = (from c in entities.ContentObject
                   where c.Id == id
                   select c).First();
         co.Downloads++;
         entities.SaveChanges(true);
     }
 }
 public void DeleteContentObject(int id)
 {
     using (vwarEntities entitiles = new vwarEntities(_ConnectionString))
     {
         var contentObejct = (from co in entitiles.ContentObject
                              where co.Id == id
                              select co).First();
         entitiles.DeleteObject(contentObejct);
         entitiles.SaveChanges(true);
     }
 }
Esempio n. 3
0
 public void InsertContentObject(ContentObject co)
 {
     using (vwarEntities entities = new vwarEntities(_ConnectionString))
     {
         var count = (from c in entities.ContentObject
                      where c.Title == co.Title
                      select c).Count();
         if (count > 0)
         {
             throw new ArgumentException("A content object with that title already exists");
         }
         entities.AddToContentObject(co);
         entities.SaveChanges(true);
         if (!String.IsNullOrEmpty(co.SubmitterLogoImageFilePath) && co.SubmitterLogoImageFilePath.Contains('.'))
         {
             co.SubmitterLogoImageFilePath = co.Id + co.SubmitterLogoImageFilePath.Substring(co.SubmitterLogoImageFilePath.LastIndexOf("."));
         }
         entities.SaveChanges(true);
     }
 }
Esempio n. 4
0
 public void DeleteContentObject(int id)
 {
     using (vwarEntities entitiles = new vwarEntities(_ConnectionString))
     {
         var contentObejct = (from co in entitiles.ContentObject
                              where co.Id == id
                              select co).First();
         entitiles.DeleteObject(contentObejct);
         entitiles.SaveChanges(true);
     }
 }
Esempio n. 5
0
 public void UpdateContentObject(ContentObject co)
 {
     using (vwarEntities entities = new vwarEntities(_ConnectionString))
     {
         var oldCo = entities.ContentObject.First((x) => x.Id == co.Id);
         oldCo.Title = co.Title;
         oldCo.DescriptionWebsiteURL = co.DescriptionWebsiteURL;
         oldCo.Keywords   = co.Keywords;
         oldCo.Location   = String.IsNullOrEmpty(co.Location) ? oldCo.Location : co.Location;
         oldCo.ScreenShot = String.IsNullOrEmpty(co.ScreenShot) ? oldCo.ScreenShot : co.ScreenShot;
         oldCo.SubmitterLogoImageFilePath = String.IsNullOrEmpty(co.SubmitterLogoImageFilePath) ? oldCo.SubmitterLogoImageFilePath : co.SubmitterLogoImageFilePath;
         entities.SaveChanges();
     }
 }
 public ContentObject GetContentObjectById(int id, bool updateViews)
 {
     using (vwarEntities entities = new vwarEntities(_ConnectionString))
     {
         var contentObject = (from co in entities.ContentObject
                              where co.Id == id
                              select co).First();
         contentObject.Reviews.Load();
         if (updateViews)
         {
             contentObject.Views++;
             contentObject.LastViewed = DateTime.Now;
             entities.SaveChanges(true);
         }
         return contentObject;
     }
 }
Esempio n. 7
0
 public void InsertReview(int rating, string text, string submitterEmail, int contentObjectId)
 {
     using (vwarEntities entities = new vwarEntities(_ConnectionString))
     {
         var review = new Reviews()
         {
             ReviewText  = text,
             SubmittedBy = submitterEmail,
             Rating      = rating
         };
         review.ContentObject = (from co in entities.ContentObject
                                 where co.Id == contentObjectId
                                 select co).First();
         review.ContentObject.Reviews.Add(review);
         entities.SaveChanges(true);
     }
 }
Esempio n. 8
0
 public ContentObject GetContentObjectById(int id, bool updateViews)
 {
     using (vwarEntities entities = new vwarEntities(_ConnectionString))
     {
         var contentObject = (from co in entities.ContentObject
                              where co.Id == id
                              select co).First();
         contentObject.Reviews.Load();
         if (updateViews)
         {
             contentObject.Views++;
             contentObject.LastViewed = DateTime.Now;
             entities.SaveChanges(true);
         }
         return(contentObject);
     }
 }
 public void UpdateContentObject(ContentObject co)
 {
     using (vwarEntities entities = new vwarEntities(_ConnectionString))
     {
         var oldCo = entities.ContentObject.First((x) => x.Id == co.Id);
         oldCo.Title = co.Title;
         oldCo.DescriptionWebsiteURL = co.DescriptionWebsiteURL;
         oldCo.Keywords = co.Keywords;
         oldCo.Location = String.IsNullOrEmpty(co.Location) ? oldCo.Location : co.Location;
         oldCo.ScreenShot = String.IsNullOrEmpty(co.ScreenShot) ? oldCo.ScreenShot : co.ScreenShot;
         oldCo.SubmitterLogoImageFilePath = String.IsNullOrEmpty(co.SubmitterLogoImageFilePath) ? oldCo.SubmitterLogoImageFilePath : co.SubmitterLogoImageFilePath;
         entities.SaveChanges();
     }
 }
Esempio n. 10
0
 public void InsertReview(int rating, string text, string submitterEmail, int contentObjectId)
 {
     using (vwarEntities entities = new vwarEntities(_ConnectionString))
     {
         var review = new Reviews()
         {
             ReviewText = text,
             SubmittedBy = submitterEmail,
             Rating = rating
         };
         review.ContentObject = (from co in entities.ContentObject
                                 where co.Id == contentObjectId
                                 select co).First();
         review.ContentObject.Reviews.Add(review);
         entities.SaveChanges(true);
     }
 }
Esempio n. 11
0
 public void InsertContentObject(ContentObject co)
 {
     using (vwarEntities entities = new vwarEntities(_ConnectionString))
     {
         var count = (from c in entities.ContentObject
                      where c.Title == co.Title
                      select c).Count();
         if (count > 0)
         {
             throw new ArgumentException("A content object with that title already exists");
         }
         entities.AddToContentObject(co);
         entities.SaveChanges(true);
         if (!String.IsNullOrEmpty(co.SubmitterLogoImageFilePath) && co.SubmitterLogoImageFilePath.Contains('.'))
         {
             co.SubmitterLogoImageFilePath = co.Id + co.SubmitterLogoImageFilePath.Substring(co.SubmitterLogoImageFilePath.LastIndexOf("."));
         }
         entities.SaveChanges(true);
     }
 }
Esempio n. 12
0
 public void IncrementDownloads(int id)
 {
     using (vwarEntities entities = new vwarEntities(_ConnectionString))
     {
         var co = (from c in entities.ContentObject
                   where c.Id == id
                   select c).First();
         co.Downloads++;
         entities.SaveChanges(true);
     }
 }