public void Vote(int idDetailPemilu) { SaveResponse response = new SaveResponse(); SaveRequest <Entities.TbPollingPemiluRow> request = new SaveRequest <TbPollingPemiluRow>(); TbPollingPemiluRepository repository = new TbPollingPemiluRepository(); TbPollingPemiluRow newRow = new TbPollingPemiluRow(); newRow.IdDetailPemilu = idDetailPemilu; using (var connection = SqlConnections.NewByKey("Rukuntangga")) using (var uow = new UnitOfWork(connection)) { { request.Entity = newRow; response = repository.Create(uow, request); uow.Commit(); } } }
public ActionResult IsVoted(int idPemilu) { RetrieveRequest request = new RetrieveRequest(); RetrieveResponse <TbPollingPemiluRow> response = new RetrieveResponse <TbPollingPemiluRow>(); TbPollingPemiluRepository repository = new TbPollingPemiluRepository(); bool result = false; var ud = (UserDefinition)Serenity.Authorization.UserDefinition; string nik = ud.Ktp.Nik; //string conString = ConfigurationManager.ConnectionStrings["Rukuntangga"].ConnectionString; //using (SqlConnection connection = new SqlConnection(conString)) //{ } using (var connection = SqlConnections.NewByKey("Rukuntangga")) { var data = (List <TbPollingPemiluRow>)connection.Query <TbPollingPemiluRow>("SpPollingPemiluSelectByNik", param: new { Nik = nik, IdPemilu = idPemilu }, commandType: System.Data.CommandType.StoredProcedure); if (data.Count > 0) { result = true; } } return(Json(result)); }