/// <summary> /// Removes the setting. /// </summary> /// <param name="entity">The setting.</param> public void RemoveSetting(Setting entity) { try { if (entity == null) throw new ArgumentNullException("entity"); _uswopContext.Settings.Remove(entity); _uswopContext.SaveChanges(); } catch (DbEntityValidationException dbEx) { var msg = string.Empty; foreach (var validationErrors in dbEx.EntityValidationErrors) foreach (var validationError in validationErrors.ValidationErrors) msg += string.Format("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage) + Environment.NewLine; var fail = new Exception(msg, dbEx); //Debug.WriteLine(fail.Message, fail); throw fail; } }
/// <summary> /// Gets the name of the setting by user. /// </summary> /// <param name="username">The user name.</param> /// <returns></returns> public Setting GetSettingByUserName(string username) { var setting = _uswopContext.Settings.FirstOrDefault(s => s.UserName == username); if (setting == null) { setting = new Setting() { Culture = "en-US" }; AddSetting(setting); } return setting; }