public async Task AddAsync(LoggingDto dto) { var model = ConvertHelper.ChangeType <Logging>(dto); model.AddTime = DateTime.Now; model.Status = 1; await this.LoggingRepository.AddAsync(model); }
public async Task <object> Post([FromBody] LoggingViewModel model) { MessageBase2 result = new MessageBase2(); LoggingDto dto = ConvertHelper.ChangeType <LoggingDto>(model); await _loggingService.AddAsync(dto); return(result); }
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()); }
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); }
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; } }
public LoggingDto GetLog(Guid id) { return(LoggingDto.CreateFromEntity(_dbContext.LoggingEntities.First(x => x.Id == id))); }