예제 #1
0
        /// <summary>
        /// Add a new TopicLog entry
        /// </summary>
        /// <param name="topicLog">the entry to add</param>
        public async Task AddTopicLogAsync(TopicLog topicLog)
        {
            topicLog.Timestamp = DateTime.UtcNow;
            await _context.TopicLog.AddAsync(topicLog);

            _context.SaveChanges();
        }
예제 #2
0
        public async Task <JsonResult> SaveTopicLog(TopicLog log)
        {
            using (TopicLogRepository repo = new TopicLogRepository())
            {
                var res = await repo.AddOrUpdateAsync(log);

                return(Json(new { isOk = res }));
            }
        }
예제 #3
0
        public async Task <bool> AddOrUpdateAsync(TopicLog logPara)
        {
            var isAdd  = false;
            var newLog = await context.TopicLogs.Where(p => p.Tid == logPara.Tid).FirstOrDefaultAsync();

            if (newLog == null)
            {
                isAdd  = true;
                newLog = new TopicLog()
                {
                    Topic = logPara.Topic, TopicID = logPara.TopicID
                };
            }
            newLog.addDate  = logPara.addDate;
            newLog.ModuleID = logPara.ModuleID;
            newLog.Contents = logPara.Contents;
            if (isAdd)
            {
                context.TopicLogs.Add(newLog);
            }
            return(await context.SaveChangesAsync() == 1);
        }