private static Poll DBMapping(DBPoll dbItem) { if (dbItem == null) return null; Poll item = new Poll(); item.PollID = dbItem.PollID; item.LanguageID = dbItem.LanguageID; item.Name = dbItem.Name; item.SystemKeyword = dbItem.SystemKeyword; item.Published = dbItem.Published; item.DisplayOrder = dbItem.DisplayOrder; return item; }
/// <summary> /// Updates the poll /// </summary> /// <param name="poll">Poll</param> public void UpdatePoll(Poll poll) { if (poll == null) throw new ArgumentNullException("poll"); poll.Name = CommonHelper.EnsureNotNull(poll.Name); poll.Name = CommonHelper.EnsureMaximumLength(poll.Name, 400); poll.SystemKeyword = CommonHelper.EnsureNotNull(poll.SystemKeyword); poll.SystemKeyword = CommonHelper.EnsureMaximumLength(poll.SystemKeyword, 400); poll.SystemKeyword = poll.SystemKeyword.Trim(); if (!_context.IsAttached(poll)) _context.Polls.Attach(poll); _context.SaveChanges(); if (this.CacheEnabled) { _cacheManager.RemoveByPattern(POLLS_PATTERN_KEY); _cacheManager.RemoveByPattern(POLLANSWERS_PATTERN_KEY); } }
public Poll SaveInfo() { Poll poll = this.PollService.GetPollById(this.PollId); DateTime? startDate = ctrlStartDate.SelectedDate; DateTime? endDate = ctrlEndDate.SelectedDate; if (startDate.HasValue) { startDate = DateTime.SpecifyKind(startDate.Value, DateTimeKind.Utc); } if (endDate.HasValue) { endDate = DateTime.SpecifyKind(endDate.Value, DateTimeKind.Utc); } if (poll != null) { poll.LanguageId = int.Parse(this.ddlLanguage.SelectedItem.Value); poll.Name = txtName.Text; poll.SystemKeyword = txtSystemKeyword.Text; poll.Published = cbPublished.Checked; poll.ShowOnHomePage = cbShowOnHomePage.Checked; poll.DisplayOrder = txtDisplayOrder.Value; poll.StartDate = startDate; poll.EndDate = endDate; this.PollService.UpdatePoll(poll); } else { poll = new Poll() { LanguageId = int.Parse(this.ddlLanguage.SelectedItem.Value), Name = txtName.Text, SystemKeyword = txtSystemKeyword.Text, Published = cbPublished.Checked, ShowOnHomePage = cbShowOnHomePage.Checked, DisplayOrder = txtDisplayOrder.Value, StartDate = startDate, EndDate = endDate }; this.PollService.InsertPoll(poll); } return poll; }