public static mdlConfig Create(mdlConfig config) { using (apiDBContext context = new apiDBContext()) { Config dbConfig = context.Config.Add(new Config() { ConfigName = config.ConfigName, ConfigValue = config.ConfigValue }).Entity; context.SaveChanges(); return(new mdlConfig() { Id = dbConfig.Id, ConfigName = dbConfig.ConfigName, ConfigValue = dbConfig.ConfigValue }); } }
public static mdlConfig Update(mdlConfig config) { using (apiDBContext context = new apiDBContext()) { Config dbConfig = context.Config.Where(c => c.Id == config.Id).FirstOrDefault(); dbConfig.ConfigName = config.ConfigName; dbConfig.ConfigValue = config.ConfigValue; Config entityConfig = context.Config.Update(dbConfig).Entity; context.SaveChanges(); return(new mdlConfig() { Id = entityConfig.Id, ConfigName = entityConfig.ConfigName, ConfigValue = entityConfig.ConfigValue }); } }
public ActionResult Put([FromBody] mdlConfig config) { return(Ok(ConfigService.Update(config))); }