public void DeleteEventRatingContext(sp_EventRating_DM InputRating)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var RatingToRemove = (from n in context.tblEventRatings where n.RatingID == InputRating.RatingID select n).FirstOrDefault();
                context.tblEventRatings.Remove(RatingToRemove);
                context.SaveChanges();

            }
        }
        public void DeleteEventRatingContext(sp_EventRating_DM _cRating)
        {
            System.Web.Caching.Cache cache = HttpRuntime.Cache;

            sp_EventRating_DM cacheRating;
            cacheRating = (sp_EventRating_DM)cache[_cRating.RatingID.ToString()];

            if (cacheRating != null)
            {
                cache.Remove(_cRating.RatingID.ToString());
            }
            BLL.DeleteEventRatingContext(_cRating);
        }
        public void UpdateEventRatingContext(sp_EventRating_DM _cRating)
        {
            System.Web.Caching.Cache cache = HttpRuntime.Cache;

            sp_EventRating_DM cacheRating;
            cacheRating = (sp_EventRating_DM)cache[_cRating.RatingID.ToString()];

            if (cacheRating != null)
            {
                cache.Remove(_cRating.RatingID.ToString());
            }

            cache.Insert(_cRating.RatingID.ToString(), _cRating, null, DateTime.Now.AddSeconds(60), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, null);
            BLL.UpdateEventRatingContext(_cRating);
        }
Beispiel #4
0
        public void TestEventRatingCreate()
        {
            DateTime StartDate = new DateTime(2014, 05, 01, 10, 0, 0);
            DateTime EndDate = new DateTime(2014, 05, 02, 11, 0, 0);
            var EventRating_bll = new sp_EventRating_BLL();
            var EventRating_dm = new sp_EventRating_DM();
            var Event_bll = new sp_ProjectEvent_BLL();

            var allEvents = Event_bll.ListEvents();
            Assert.IsTrue(allEvents.Count > 0, "The ListEventRatings() is broken, or no data in DB");
            EventRating_dm.EventID = allEvents[0].EventID;
            EventRating_dm.ActiveFlg = true;
            int RatingID = EventRating_bll.InsertEventRatingContext(EventRating_dm).RatingID;
            EventRating_dm.RatingID = RatingID;

            var EventRating_dm_selected = EventRating_bll.ListEventRatings(RatingID);
            Assert.IsTrue(Equals(EventRating_dm, EventRating_dm_selected));
        }
        public sp_EventRating_DM InsertEventRatingContext(sp_EventRating_DM InputRating)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var NewEventRating = new tblEventRating
                {
                    RatingID = InputRating.RatingID,
                    EventID = InputRating.EventID,
                    VolID = InputRating.VolID,
                    RatingValue = InputRating.RatingValue,
                    ActiveFlg = InputRating.ActiveFlg

                };
                context.tblEventRatings.Add(NewEventRating);
                context.SaveChanges();

                InputRating.RatingID = NewEventRating.RatingID;
                return InputRating;
            }
        }
        /// <summary>
        /// ListEventRatings - There's a good chance the same record may be requested often.  Cache the event rating object...
        /// 
        /// </summary>
        /// <param name="EventRating"></param>
        /// <returns></returns>
        public sp_EventRating_DM ListEventRatings(int? EventRating)
        {
            sp_EventRating_DM cRating = new sp_EventRating_DM();

            //Cache cache = HttpRuntime.Cache;
            System.Web.Caching.Cache cache = HttpRuntime.Cache;

            sp_EventRating_DM cacheRating;
            cacheRating = (sp_EventRating_DM)cache[EventRating.ToString()];

            if (cacheRating == null)
            {
                cRating = BLL.ListEventRatings(EventRating);
                cache.Insert(cRating.RatingID.ToString(), cRating, null, DateTime.Now.AddSeconds(60), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, null);
            }
            else
            {
                cRating = cacheRating;
            }

            return cRating;
        }
        public void UpdateEventRatingContext(sp_EventRating_DM InputRating)
        {
            using (VolTeerEntities context = new VolTeerEntities())
            {
                var ExistingRating = context.tblEventRatings.Find(InputRating.RatingID);

                if (ExistingRating != null)
                {
                    ExistingRating.EventID = InputRating.EventID;
                    ExistingRating.RatingID = InputRating.RatingID;
                    ExistingRating.RatingValue = InputRating.RatingValue;
                    ExistingRating.ActiveFlg = InputRating.ActiveFlg;
                    context.SaveChanges();
                }
            }
        }
 public void UpdateEventRatingContext(sp_EventRating_DM _cEventRating)
 {
     DAL.UpdateEventRatingContext(_cEventRating);
 }
 public sp_EventRating_DM InsertEventRatingContext(sp_EventRating_DM _cEventRating)
 {
     return DAL.InsertEventRatingContext(_cEventRating);
 }
 public void DeleteEventRatingContext(sp_EventRating_DM _cEventRating)
 {
     DAL.DeleteEventRatingContext(_cEventRating);
 }
Beispiel #11
0
 private static bool Equals(sp_EventRating_DM dm1, sp_EventRating_DM dm2)
 {
     return (dm1.RatingID == dm2.RatingID &&
             dm1.EventID == dm2.EventID &&
             dm1.VolID == dm2.VolID &&
             dm1.RatingValue == dm2.RatingValue &&
             dm1.ActiveFlg == dm2.ActiveFlg
             );
 }
Beispiel #12
0
 private static List<sp_EventRating_DM> DMsFrom(DataTable dataTable)
 {
     var DMs = new List<sp_EventRating_DM>();
     for (int i = 0; i < dataTable.Rows.Count; i++)
     {
         var returnEventRating = new sp_EventRating_DM();
         returnEventRating.RatingID = Convert.ToInt32(dataTable.Rows[i]["RatingID"]);
         returnEventRating.EventID = new Guid((String)dataTable.Rows[i]["EventID"]);
         returnEventRating.VolID = new Guid((String)dataTable.Rows[i]["VolID"]);
         returnEventRating.RatingValue = Convert.ToInt32(dataTable.Rows[i]["RatingValue"]);
         returnEventRating.ActiveFlg = Convert.ToBoolean(dataTable.Rows[i]["ActiveFlg"]);
         DMs.Add(returnEventRating);
     }
     return DMs;
 }
 public void InsertEventRatingContext(sp_EventRating_DM _cRating)
 {
     BLL.InsertEventRatingContext(_cRating);
     System.Web.Caching.Cache cache = HttpRuntime.Cache;
     cache.Insert(_cRating.RatingID.ToString(), _cRating, null, DateTime.Now.AddSeconds(60), System.Web.Caching.Cache.NoSlidingExpiration, CacheItemPriority.High, null);
 }