public GroupEnergy DeleteGroupEnergy(int id) { GroupEnergy dbEntry = context.GroupEnergy.Find(id); if (dbEntry != null) { try { context.GroupEnergy.Remove(dbEntry); context.SaveChanges(); } catch (Exception e) { e.WriteErrorMethod(String.Format("DeleteGroupEnergy(id={0})", id), eventID); return(null); } } return(dbEntry); }
public int SaveGroupEnergy(GroupEnergy GroupEnergy) { GroupEnergy dbEntry; try { if (GroupEnergy.id == 0) { dbEntry = new GroupEnergy() { id = 0, group_energy_ru = GroupEnergy.group_energy_ru, group_energy_en = GroupEnergy.group_energy_en, TypeEnergy = GroupEnergy.TypeEnergy }; context.GroupEnergy.Add(dbEntry); } else { dbEntry = context.GroupEnergy.Find(GroupEnergy.id); if (dbEntry != null) { dbEntry.group_energy_ru = GroupEnergy.group_energy_ru; dbEntry.group_energy_en = GroupEnergy.group_energy_en; dbEntry.TypeEnergy = GroupEnergy.TypeEnergy; } } context.SaveChanges(); } catch (Exception e) { e.WriteErrorMethod(String.Format("SaveGroupEnergy(GroupEnergy={0})", GroupEnergy.GetFieldsAndValue()), eventID); return(-1); } return(dbEntry.id); }
public string GetNameGroupEnergyCulture(int id) { try { GroupEnergy group = GetGroupEnergy(id); if (group == null) { return(null); } if (CultureInfo.CurrentUICulture.Name == "en-US") { return(group.group_energy_en); } else { return(group.group_energy_ru); } } catch (Exception e) { e.WriteErrorMethod(String.Format("GetNameGroupEnergyCulture(id={0})", id), eventID); return(null); } }