示例#1
0
        /// <summary>
        /// Clears all dictionaries and indexes and loads them with current data
        /// </summary>
        public void ClearAndFill()
        {
            ResetSearch();

            // get a list of valid restaurants
            ICollection<restaurant> restos = new RestaurantIM().find(false);

            foreach (var resto in restos)
            {
                // clear the index
                invertedIndex = new Dictionary<string, IDictionary<int, IList<int>>>();

                // load the dictionary (any previous data will be overwritten)
                dictionary = LoadDictionary(resto.id);

                // fill class variable invertedIndex
                CreateInvertedIndex();

                dictionaryHolder.Add(resto.id, dictionary);
                indexHolder.Add(resto.id, invertedIndex);
            }

            HttpContext.Current.Application.Lock();
            HttpContext.Current.Application["dictionary"] = dictionaryHolder;
            HttpContext.Current.Application["invertedIndex"] = indexHolder;
            HttpContext.Current.Application.UnLock();
        }
示例#2
0
 public RestaurantController()
 {
     im = new RestaurantIM(db);
     om = new RestaurantOM(db);
 }
示例#3
0
 /// <summary>
 /// when updating a record we would like to increment the value of version to
 /// </summary>
 /// <param name="restaurant"></param>
 /// <returns></returns>
 /// <exception cref="InvalidOperationException"></exception>
 public Boolean edit(restaurant restaurant)
 {
     RestaurantIM im = new RestaurantIM(db);
     restaurant dbVersion = im.find(restaurant.id);
     if (dbVersion.version == restaurant.version)
     {
         ((IObjectContextAdapter)db).ObjectContext.Detach(dbVersion);
         db.Entry(restaurant).State = EntityState.Modified;
         restaurant.version = restaurant.version + 1;
         db.SaveChanges();
         return true;
     }
     return false;
 }