public virtual PollVotingRecord UpdatePollVotingRecord(PollVotingRecord entity) { if (entity.IsTransient()) { return(entity); } PollVotingRecord other = GetPollVotingRecord(entity.PollVotingRecordId); if (entity.Equals(other)) { return(entity); } string sql = @"Update PollVotingRecord set [PollVotingRecordGUID]=@PollVotingRecordGUID , [PollID]=@PollID , [PollAnswerID]=@PollAnswerID , [CustomerID]=@CustomerID , [CreatedOn]=@CreatedOn where PollVotingRecordID=@PollVotingRecordID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@PollVotingRecordID", entity.PollVotingRecordId) , new SqlParameter("@PollVotingRecordGUID", entity.PollVotingRecordGuid) , new SqlParameter("@PollID", entity.PollId) , new SqlParameter("@PollAnswerID", entity.PollAnswerId) , new SqlParameter("@CustomerID", entity.CustomerId) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetPollVotingRecord(entity.PollVotingRecordId)); }
public void InsertPollVoit(PollVotingRecord pollVotingRecord) { if (pollVotingRecord == null) { throw new ArgumentNullException(nameof(pollVotingRecord)); } _pollVotingRecordRepository.Insert(pollVotingRecord); }
public PollChoiceItemQuery WithVotingRecord(PollVotingRecord value = null, ArgumentEvaluationMode mode = ArgumentEvaluationMode.IgnoreNeutral, CollectionOperator @operator = CollectionOperator.Equal, CollectionDirection direction = CollectionDirection.Any) { switch (mode) { case ArgumentEvaluationMode.IgnoreNeutral: if (Neutrals.Is(value)) { return(this); } break; case ArgumentEvaluationMode.Explicit: break; default: throw new NotSupportedEnumException(mode); } switch (@operator) { case CollectionOperator.Equal: switch (direction) { case CollectionDirection.Any: Entities = Entities.Where(pci => pci.VotingRecords.Any(pvr => pvr == value)); return(this); case CollectionDirection.All: Entities = Entities.Where(pci => pci.VotingRecords.All(pvr => pvr == value)); return(this); default: throw new NotSupportedEnumException(direction); } case CollectionOperator.NotEqual: switch (direction) { case CollectionDirection.Any: Entities = Entities.Where(pci => pci.VotingRecords.Any(pvr => pvr != value)); return(this); case CollectionDirection.All: Entities = Entities.Where(pci => pci.VotingRecords.All(pvr => pvr != value)); return(this); default: throw new NotSupportedEnumException(direction); } default: throw new NotSupportedEnumException(@operator); } }
public int InsertPollVotingRecord(PollVotingRecord pollVotingRecord) { if (pollVotingRecord == null) { throw new ArgumentNullException(nameof(pollVotingRecord)); } dbContext.PollVotingRecords.Add(pollVotingRecord); dbContext.SaveChanges(); return(pollVotingRecord.Id); }
/// <summary> /// Inserts a poll voting record /// </summary> /// <param name="pollVotingRecord">Voting record</param> public virtual void InsertPollVotingRecord(PollVotingRecord pollVotingRecord) { if (pollVotingRecord == null) { throw new ArgumentNullException(nameof(pollVotingRecord)); } _pollVotingRecordRepository.Insert(pollVotingRecord); //event notification _eventPublisher.EntityInserted(pollVotingRecord); }
public bool UpdatePollVotingRecord(PollVotingRecord entity) { var pollVotingRecord = dbContext.PollVotingRecords.Find(entity.Id); if (pollVotingRecord == null) { throw new ArgumentNullException(nameof(pollVotingRecord)); } pollVotingRecord.PollAnswerId = entity.PollAnswerId; pollVotingRecord.CustomerId = entity.CustomerId; return(true); }
public virtual PollVotingRecord PollVotingRecordFromDataRow(DataRow dr) { if (dr == null) { return(null); } PollVotingRecord entity = new PollVotingRecord(); entity.PollVotingRecordId = (System.Int32)dr["PollVotingRecordID"]; entity.PollVotingRecordGuid = (System.Guid)dr["PollVotingRecordGUID"]; entity.PollId = (System.Int32)dr["PollID"]; entity.PollAnswerId = (System.Int32)dr["PollAnswerID"]; entity.CustomerId = (System.Int32)dr["CustomerID"]; entity.CreatedOn = (System.DateTime)dr["CreatedOn"]; return(entity); }
public virtual IActionResult Vote(int id) { PollAnswer pollAnswer = _pollService.GetPollAnswerById(id); if (pollAnswer == null) { return(Json(new { error = "No poll answer found with the specified id" })); } Poll poll = pollAnswer.Poll; if (!poll.Published) { return(Json(new { error = "Poll is not available" })); } if (!poll.AllowGuestsToVote) { return(Json(new { error = "Yanlız Kayıtlı Kullanıcılar Oylayabilirler" })); } bool alreadyVoted = _pollService.AlreadyVoted(poll.Id); if (!alreadyVoted) { //vote var pollVoitRecord = new PollVotingRecord { PollAnswerId = pollAnswer.Id, CustomerId = User.GetCustomer(_userManager, _customerService) == null ? 5 : User.GetCustomer(_userManager, _customerService).Id, CreatedOnUtc = DateTime.UtcNow }; _pollService.InsertPollVoit(pollVoitRecord); //update totals pollAnswer.NumberOfVotes = pollAnswer.PollVotingRecords.Count; _pollService.UpdatePoll(poll); } return(Json(new { html = RenderPartialViewToString("_Poll", _pollModelFactory.PreparePollModel(poll, true)) })); }
protected virtual object CreateModelPart(PollVotingRecord part, MessageContext messageContext) { Guard.NotNull(messageContext, nameof(messageContext)); Guard.NotNull(part, nameof(part)); var m = new Dictionary <string, object> { { "PollAnswerId", part.PollAnswerId }, { "PollAnswerName", part.PollAnswer.Name }, { "PollId", part.PollAnswer.PollId } }; ApplyCustomerContentPart(m, part, messageContext); PublishModelPartCreatedEvent <PollVotingRecord>(part, m); return(m); }
public virtual PollVotingRecord InsertPollVotingRecord(PollVotingRecord entity) { PollVotingRecord other = new PollVotingRecord(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into PollVotingRecord ( [PollVotingRecordGUID] ,[PollID] ,[PollAnswerID] ,[CustomerID] ,[CreatedOn] ) Values ( @PollVotingRecordGUID , @PollID , @PollAnswerID , @CustomerID , @CreatedOn ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@PollVotingRecordID", entity.PollVotingRecordId) , new SqlParameter("@PollVotingRecordGUID", entity.PollVotingRecordGuid) , new SqlParameter("@PollID", entity.PollId) , new SqlParameter("@PollAnswerID", entity.PollAnswerId) , new SqlParameter("@CustomerID", entity.CustomerId) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray); if (identity == DBNull.Value) { throw new DataException("Identity column was null as a result of the insert operation."); } return(GetPollVotingRecord(Convert.ToInt32(identity))); } return(entity); }
public PollVotingRecord Update(PollVotingRecord entity) { return(Channel.Update(entity)); }
public virtual PollVotingRecord DeletePollVotingRecord(PollVotingRecord entity) { this.DeletePollVotingRecord(entity.PollVotingRecordId); return(entity); }
/// <summary> /// Inserts a poll voting record /// </summary> /// <param name="pollVotingRecord">Voting record</param> public virtual void InsertPollVotingRecord(PollVotingRecord pollVotingRecord) { _pollVotingRecordRepository.Insert(pollVotingRecord); }
public PollVotingRecord InsertPollVotingRecord(PollVotingRecord entity) { return(_iPollVotingRecordRepository.InsertPollVotingRecord(entity)); }
public PollVotingRecord UpdatePollVotingRecord(PollVotingRecord entity) { return(_iPollVotingRecordRepository.UpdatePollVotingRecord(entity)); }
/// <summary> /// Inserts a poll voting record /// </summary> /// <param name="pollVotingRecord">Voting record</param> public virtual async Task InsertPollVotingRecordAsync(PollVotingRecord pollVotingRecord) { await _pollVotingRecordRepository.InsertAsync(pollVotingRecord); }
public PollVotingRecord Update(PollVotingRecord entity) { throw new NotImplementedException(); }