Esempio n. 1
0
        public bool DeleteHistory(string userId, ngHistoryGroupEntry group)
        {
            ngUserModel user = UsersManager.Inst.GetUserById(userId);
            ngHistoryModel model = HistoryManager.Inst.GetHistoryModelByUser(user);
            DateTime dateTime = DateTime.Parse(@group.DateStr);
            List<ngHistoryEntry> entriesByDate = model.GetEntriesByDate(dateTime);
            foreach (ngHistoryEntry entry in entriesByDate) {
                bool res = model.Entries.Remove(entry);
                Debug.Assert(res);
            }
            HistoryManager.Inst.Save();

            return true;
        }
Esempio n. 2
0
 internal List<ngHistoryGroupEntry> GroupByDate(int dayOfWeek)
 {
     List<ngHistoryGroupEntry> res = new List<ngHistoryGroupEntry>();
     foreach (ngHistoryEntry entry in Entries)
     {
         ngFoodItem food = FoodManager.Inst.GetFoodById(entry.FoodId);
         int ofWeek = (int)entry.Date.DayOfWeek;
         if (null != food && !food.isContainer && (ofWeek == dayOfWeek + 1))
         {
             string key = entry.Date.ToShortDateString();
             if (!HasGroupByDate(res, key))
             {
                 ngHistoryGroupEntry newGroup = new ngHistoryGroupEntry();
                 newGroup.DateStr = key;
                 res.Add(newGroup);
             }
             GetGroupByDate(res, key).Entries.Add(entry);
         }
     }
     return res;
 }
Esempio n. 3
0
 public void deleteHistoryClick(ngHistoryGroupEntry group)
 {
     ajaxHlp.inst.SendPost("json",
         HistoryUrl.c_sDeleteHistoryPrefix + "/" + ngAppController.inst.ngUserId + "/",JSON.stringify(group),
         delegate { refreshHistory(); }, onRequestFailed);
 }