/// <summary> /// Adds the application configuration. /// </summary> /// <param name="applicationCode">The application code.</param> /// <param name="enableOmsConfig">if set to <c>true</c> [enable oms configuration].</param> /// <returns></returns> public DataResponse <string> AddApplicationConfiguration(string applicationCode, bool enableOmsConfig) { try { List <Component> componentList = _context.Components.ToList(); foreach (Component item in componentList) { ComponentConfiguration appComponentConfiguration = _context.ComponentConfigurations.Where(x => x.ApplicationCode == applicationCode && x.ComponentId == item.ComponentId).FirstOrDefault(); if (appComponentConfiguration != null) { appComponentConfiguration.IsOmsLog = enableOmsConfig; appComponentConfiguration.ModifiedDate = DateTime.UtcNow; appComponentConfiguration.ModifiedBy = Guid.Parse("200EDCFA-8FF1-4837-91B1-7D5F967F5129"); _context.SaveChanges(); } else { ComponentConfiguration componentConfig = new ComponentConfiguration() { ApplicationCode = applicationCode, ComponentConfigId = Guid.NewGuid(), ComponentId = item.ComponentId, CreatedDate = DateTime.UtcNow, Debug = false, Error = true, Fatal = true, Info = true, IsOmsLog = enableOmsConfig, KeyName = $"{item.Name.Trim()}Key", Warn = true, ModifiedDate = DateTime.UtcNow, CreatedBy = Guid.Parse("200EDCFA-8FF1-4837-91B1-7D5F967F5129"), ModifiedBy = Guid.Parse("200EDCFA-8FF1-4837-91B1-7D5F967F5129"), SubscribeError = true, SubscribeDebug = true, CronJobDebug = false, CronJobError = true, CronJobFatal = true, CronJobInfo = true, CronJobWarn = true, }; _context.Add(componentConfig); _context.SaveChanges(); } } return(new DataResponse <string>() { Status = DataResponseStatus.Success, Data = string.Empty }); } catch (Exception ex) { throw ex; } }
public void Add(LogEntity log) { _context.Add(log); _context.SaveChanges(); }