private static SectionItem createItem(DataRow row, bool shortInfo, DateTime startDate, int?cityId = null) { var item = new SectionItem(row[NameDict.id], row[NameDict.name]); if (!shortInfo) { item.info = ConferenceItem.getBySection(row[NameDict.id], row[NameDict.name].ToString(), startDate, cityId); } return(item); }
public static bool saveOrUpdate(string sectionName, ConferenceItem changedItem) { var sectionRow = getSecionRowByName(sectionName); if (sectionRow != null) { var row = TableManager.SelectRowByPrimaryKey(NameDict.conference, changedItem.id); bool isNew = row == null; var newConference = ConferenceItem.saveOrUpdate(changedItem, row, sectionName); if (isNew) { createLink(sectionRow[NameDict.id], newConference.id); } return(true); } return(false); }
public static ConferenceItem saveOrUpdate(ConferenceItem changedItem, DataRow row, string sectionName) { bool isNew = row == null; var newRow = TableManager.GetTable(NameDict.conference).NewRow(); newRow[NameDict.id] = isNew ? TableManager.GetNewId(NameDict.conference) : row[NameDict.id]; newRow[NameDict.name] = changedItem.name; newRow[NameDict.event_date] = changedItem.date; newRow[NameDict.city_id] = changedItem.city; newRow[NameDict.address] = changedItem.location; if (isNew) { TableManager.InsertRow(row); } else { TableManager.UpdateRecord(row, newRow); } return(createItem(newRow, sectionName)); }
private static ConferenceItem createItem(DataRow row, string sectionName) { var newItem = new ConferenceItem(row[NameDict.id], row[NameDict.name], row[NameDict.event_date], row[NameDict.address], row[NameDict.city_id], sectionName); return(newItem); }