コード例 #1
0
        public async Task AddAsync(LoggingDto dto)
        {
            var model = ConvertHelper.ChangeType <Logging>(dto);

            model.AddTime = DateTime.Now;
            model.Status  = 1;
            await this.LoggingRepository.AddAsync(model);
        }
コード例 #2
0
ファイル: LoggingController.cs プロジェクト: LoveHikari/52cos
        public async Task <object> Post([FromBody] LoggingViewModel model)
        {
            MessageBase2 result = new MessageBase2();
            LoggingDto   dto    = ConvertHelper.ChangeType <LoggingDto>(model);
            await _loggingService.AddAsync(dto);

            return(result);
        }
コード例 #3
0
        public List <LoggingDto> GetLogs(DateTime startTime, DateTime endTime, Dictionary <string, string> tags)
        {
            var rawResult = this._dbContext.LoggingEntities.Where(x => x.CreateTime > startTime && x.CreateTime < endTime).ToList();

            foreach (var pair in tags)
            {
                rawResult = rawResult.Where(x => x.Tags.GetValueOrDefault(pair.Key) == pair.Value.ToString()).ToList();
            }
            return(rawResult.Select(x => LoggingDto.CreateFromEntity(x)).ToList());
        }
コード例 #4
0
        public LoggingDto UpsertLog(LoggingDto dto)
        {
            if (dto.Id == default(Guid))
            {
                dto.Id = Guid.NewGuid();
            }
            var entity = dto.ToEntity();

            _dbContext.Add(entity);
            _dbContext.SaveChanges();
            return(dto);
        }
コード例 #5
0
 public LoggingDto Put([FromBody] LoggingDto loggingDto)
 {
     try
     {
         var result = _loggingService.UpsertLog(loggingDto);
         Created(Url.Action("Get", new { id = result.Id }), result);
         return(result);
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         throw;
     }
 }
コード例 #6
0
 public LoggingDto GetLog(Guid id)
 {
     return(LoggingDto.CreateFromEntity(_dbContext.LoggingEntities.First(x => x.Id == id)));
 }