How do i parse my array to my model - c#

I have made a ajax post and stringifyed my json and send the data to my controller method:
The data that the controller recieves looks like this:
"[\"0041300201\",1610612764,\"WAS\",\"Washington\",2772,\"Trevor Ariza\",\"F\",\"\",\"37:20\",7,10,0.7,6,6,1,2,4,0.5,1,5,6,2,1,0,0,3,22,18]"
My controller method:
public void addBoxScore(string playerstats)
{
Games gamestats = new Games();
gamestats.GAME_ID = playerstats[0];
gamestats.TEAM_ID = playerstats[1];
gamestats.TEAM_ABBREVIATION = playerstats[2].ToString();
gamestats.TEAM_CITY = playerstats[3].ToString();
gamestats.PLAYER_ID = playerstats[4];
gamestats.PLAYER_NAME = playerstats[5].ToString();
gamestats.START_POSITION = playerstats[6].ToString();
gamestats.COMMENT = playerstats[7].ToString();
gamestats.MIN = playerstats[8];
gamestats.FGM = playerstats[9];
gamestats.FGA = playerstats[10];
gamestats.FG_PCT = playerstats[11];
gamestats.FGTHREEM = playerstats[12];
gamestats.FGTHREEA = playerstats[13];
gamestats.FGTHREE_PCT = playerstats[14];
gamestats.FTM = playerstats[15];
gamestats.FTA = playerstats[16];
gamestats.FT_PCT = playerstats[17];
gamestats.OREB = playerstats[18];
gamestats.DREB = playerstats[19];
gamestats.REB = playerstats[20];
gamestats.AST = playerstats[21];
gamestats.STL = playerstats[22];
gamestats.BLK = playerstats[23];
gamestats.TO = playerstats[24];
gamestats.PF = playerstats[25];
gamestats.PTS = playerstats[26];
gamestats.PLUS_MINUS = playerstats[27];
}
When i do this the gamestats.Game_ID becomes "91" instead of "0041300201" as i wanted it to be.

Please use this array or list of string instead of only strings. like this
public void addBoxScore(string[] playerstats)

Related

how to return an object in c#?

I'm filling data inside an object with c# but I don't know how to return this object.
I create an object named ArasOrder and fill in the data and I want to return the ArasOrder object.
how can I do this.
public class ArasDeneme
{
public static void aras()
{
var ArasService = new ArasTEST.Service();
var ArasGonderi = new ArasTEST.ShippingOrder();
var ArasOrder = new ArasTEST.Order();
var parametreler = ArasKargoTEST.ParametreGet();
var newentegrationcode = "";
foreach (var item in parametreler)
{
var encode = entegrationcode();
var YeniGelenDesi = DesiHesabi(item.WebSiparisNo);
var yeniteminyeri = item.TeminYeri;
newentegrationcode = 123+ "" + encode;
ArasOrder.UserName = "";
ArasOrder.Password = "";
ArasOrder.ReceiverName = item.KargoAdSoyad;
ArasOrder.ReceiverPhone1 = item.KargoTelefon;
ArasOrder.ReceiverCityName = item.KargoIlAdi;
ArasOrder.ReceiverTownName = item.KargoIlceAdi;
ArasOrder.ReceiverAddress = item.KargoAdres;
ArasOrder.TradingWaybillNumber = item.WebSiparisNo;
ArasOrder.PieceCount = "1";
ArasOrder.IntegrationCode = newentegrationcode;
ArasOrder.PayorTypeCode = "1";
ArasOrder.IsWorldWide = "0";
ArasOrder.IsCod = "0";
ArasOrder.VolumetricWeight = YeniGelenDesi;
ArasOrder.SenderAccountAddressId = "1071";
ArasTEST.PieceDetail[] ArasPieceDetails = new ArasTEST.PieceDetail[1];
PieceDetail ArasPieceDetail1 = new PieceDetail();
ArasPieceDetail1.BarcodeNumber = newentegrationcode;
ArasPieceDetail1.VolumetricWeight = YeniGelenDesi;
ArasPieceDetail1.Weight = "1";
ArasPieceDetail1.Description = "";
ArasPieceDetails[0] = ArasPieceDetail1;
ArasOrder.PieceDetails = ArasPieceDetails;
var ArasOrderInfo = new ArasTEST.Order[1];
ArasOrderInfo[0] = ArasOrder;
var takipNoResult = ArasService.SetOrder("", "", "");
var ArasOrderResultInfo = takipNoResult[0];
var SonucKodu = takipNoResult[0].ResultCode;
var SonucMesaji = takipNoResult[0].ResultMessage;
var SonucInvoiceKey = takipNoResult[0].InvoiceKey;
}
}
}
You should define the return type and return the instance.
public static ArasTEST aras()
{
// insert code here...
return ArasOrder;
}
Change void to ArasDeneme return type.
Then call like:
var ad = ArasDeneme.aras();

Lightswitch Updating() method not saving any data in DB

I am trying to save the entity data using General methods of lightswitch, which is Updating. Below is the following code. I am not able to figure out what I am missing. There is no error in the code or in the UI. Its just that nothing gets saved.
partial void viewFamilyProcessDatas_Updating(viewFamilyProcessData entity)
{
var AutoAddMissingListing = entity.AutoAddMissingListing;
var AutoAddOddLots = entity.AutoAddOddLots;
var DefaultFilterValue = entity.DefaultFilterValue;
var ExcludeZeroNumberOfUnits = entity.ExcludeZeroNumberOfUnits;
//objFamilyProcessData.FamilyID = entity.FamilyID;
var IgnoreForPricing = entity.IgnoreForPricing;
var LimitEndDate = entity.LimitEndDate;
var OffsetFromMaxAsAtDate = entity.OffsetFromMaxAsAtDate;
var PrefilterConstituents = entity.PrefilterConstituents;
var TimeDataExpires = entity.TimeDataExpires;
entity.AutoAddMissingListing = AutoAddMissingListing;
entity.AutoAddOddLots = AutoAddOddLots;
entity.DefaultFilterValue = DefaultFilterValue;
entity.ExcludeZeroNumberOfUnits = ExcludeZeroNumberOfUnits;
entity.IgnoreForPricing = IgnoreForPricing;
entity.LimitEndDate = LimitEndDate;
entity.OffsetFromMaxAsAtDate = OffsetFromMaxAsAtDate;
entity.PrefilterConstituents = PrefilterConstituents;
entity.TimeDataExpires = TimeDataExpires;
//this.DataWorkspace.SolaDBServerData.Details.DiscardChanges();
entity.Details.DiscardChanges();
}
The solution to this finally came to this:
partial void vwFamilyProcessDatas_Updating(vwFamilyProcessData entity)
{
if(entity.Details.EntityState.ToString() == "Modified")
{
var AutoAddMissingListing = entity.AutoAddMissingListing;
var AutoAddOddLots = entity.AutoAddOddLots;
var DefaultFilterValue = entity.DefaultFilterValue;
var ExcludeZeroNumberOfUnits = entity.ExcludeZeroNumberOfUnits;
var IgnoreForPricing = entity.IgnoreForPricing;
var LimitEndDate = entity.LimitEndDate;
var OffsetFromMaxAsAtDate = entity.OffsetFromMaxAsAtDate;
var PrefilterConstituents = entity.PrefilterConstituents;
var TimeDataExpires = entity.TimeDataExpires;
tblFamily objFamily = tblFamilies.Where(f => f.FamilyID == entity.FamilyID).Single();
objFamily.AutoAddMissingListing = AutoAddMissingListing;
objFamily.AutoAddOddLots = AutoAddOddLots;
objFamily.DefaultFilterValue = DefaultFilterValue;
objFamily.ExcludeZeroNumberOfUnits = ExcludeZeroNumberOfUnits;
objFamily.IgnoreForPricing = IgnoreForPricing;
objFamily.LimitEndDate = LimitEndDate;
objFamily.OffsetFromMaxAsAtDate = OffsetFromMaxAsAtDate;
objFamily.PrefilterConstituents = PrefilterConstituents;
objFamily.TimeDataExpires = TimeSpan.Parse(TimeDataExpires);
entity.Details.DiscardChanges();
}}

Expedia hotel API

I am working on Expedia hotel API.All the function are working except booking.All the other request using GET method for requesting.But in booking we have to use the POST method with different URL.So i changed the URL for request but still getting the error.
My codes are
HotelServicesImplService client = new HotelServicesImplService();
HotelRoomReservationRequest bookreq = new HotelRoomReservationRequest();
HotelRoomReservationResponse bookres = new HotelRoomReservationResponse();
addressInfo bookad = new addressInfo();
reservationInfo bookinfo = new reservationInfo();
client.Url = "https://book.api.ean.com/ean-services/rs/hotel/v3";
//bookreq.minorRevSpecified = true;
//bookreq.minorRev = 25;
bookreq.hotelId = 106347;
bookreq.apiKey = "api";
bookreq.cid = "cid";
bookreq.arrivalDate = "12/11/2013";
bookreq.departureDate = "12/13/2013";
bookreq.supplierType = SupplierType.E;
bookreq.rateKey = "af00b688-acf4-409e-8bdc-fcfc3d1cb80c";
bookreq.roomTypeCode = "198058";
bookreq.rateCode = "484072";
bookreq.RoomGroup = new[] { new Room
{
numberOfAdults=Convert.ToInt32(2),
numberOfChildren=Convert.ToInt32(0),
childAges=new int[] {} ,
firstName="Test Booking",
lastName="Test Booking",
bedTypeId="23",
smokingPreference=SmokingPreference.NS,
}};
float i = float.Parse("231.18");
bookreq.currencyCode = "USD";
bookreq.chargeableRate = i;
bookinfo.email = "ranaabhi007#yahoo.com";
bookinfo.firstName = "TestBooking";
bookinfo.lastName = "TestBooking";
bookinfo.homePhone = "2145370159";
bookinfo.workPhone = "2145370159";
bookinfo.creditCardType = "CA";
bookinfo.creditCardNumber = "5401999999999999";
bookinfo.creditCardIdentifier = "TestBooking";
bookinfo.creditCardExpirationMonth = "12";
bookinfo.creditCardExpirationYear = "2015";
bookad.city = "Seattle";
bookad.stateProvinceCode = "WA";
bookad.countryCode = "US";
bookad.postalCode = "98004";
bookreq.ReservationInfo = bookinfo;
bookad.address1 = "travelnow";
//bookad.city = txtCity.Text;
//bookad.stateProvinceCode = txtState.Text;
//bookad.countryCode = txtCountry.Text;
//bookad.postalCode = txtPostal.Text;
bookreq.AddressInfo = bookad;
bookres = client.getReservation(bookreq);
// HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(client);
Response.Write(bookres.confirmationNumbers);
Response.Write(bookres.departureDate);
Response.Write(bookres.drivingDirections);
Response.Write(bookres.CouponInformationResponse);
but i am still getting the error
The request failed with HTTP status 404: Not Found.
Are you sure your URL is correct? According to the documentation, it should be
https://book.api.ean.com/ean-services/rs/hotel/v3/res

Scrape Javascript from an HTML page using C# .NET

I have Website, which i need to scrap using C# HTML Agility Pack.
On the source code, i need the Array of URL's which is a Javascript Array. Please tell me how can i get this Array in Python
And the call from HTML to Javascript is like this:
<li class="accordion"><a class="xbrlviewer" onClick="javascript:highlight(this);" href="javascript:loadReport(1);">CONSOLIDATED BALANCE SHEETS</a></li>
<script type="text/javascript" language="javascript">
var reports = new Array(61);
reports[0] = "/Archives/edgar/data/320193/000119312512444068/R1.htm";
reports[1] = "/Archives/edgar/data/320193/000119312512444068/R2.htm";
reports[2] = "/Archives/edgar/data/320193/000119312512444068/R3.htm";
reports[3] = "/Archives/edgar/data/320193/000119312512444068/R4.htm";
reports[4] = "/Archives/edgar/data/320193/000119312512444068/R5.htm";
reports[5] = "/Archives/edgar/data/320193/000119312512444068/R6.htm";
reports[6] = "/Archives/edgar/data/320193/000119312512444068/R7.htm";
reports[7] = "/Archives/edgar/data/320193/000119312512444068/R8.htm";
reports[8] = "/Archives/edgar/data/320193/000119312512444068/R9.htm";
reports[9] = "/Archives/edgar/data/320193/000119312512444068/R10.htm";
reports[10] = "/Archives/edgar/data/320193/000119312512444068/R11.htm";
reports[11] = "/Archives/edgar/data/320193/000119312512444068/R12.htm";
reports[12] = "/Archives/edgar/data/320193/000119312512444068/R13.htm";
reports[13] = "/Archives/edgar/data/320193/000119312512444068/R14.htm";
reports[14] = "/Archives/edgar/data/320193/000119312512444068/R15.htm";
reports[15] = "/Archives/edgar/data/320193/000119312512444068/R16.htm";
reports[16] = "/Archives/edgar/data/320193/000119312512444068/R17.htm";
reports[17] = "/Archives/edgar/data/320193/000119312512444068/R18.htm";
reports[18] = "/Archives/edgar/data/320193/000119312512444068/R19.htm";
reports[19] = "/Archives/edgar/data/320193/000119312512444068/R20.htm";
reports[20] = "/Archives/edgar/data/320193/000119312512444068/R21.htm";
reports[21] = "/Archives/edgar/data/320193/000119312512444068/R22.htm";
reports[22] = "/Archives/edgar/data/320193/000119312512444068/R23.htm";
reports[23] = "/Archives/edgar/data/320193/000119312512444068/R24.htm";
reports[24] = "/Archives/edgar/data/320193/000119312512444068/R25.htm";
reports[25] = "/Archives/edgar/data/320193/000119312512444068/R26.htm";
reports[26] = "/Archives/edgar/data/320193/000119312512444068/R27.htm";
reports[27] = "/Archives/edgar/data/320193/000119312512444068/R28.htm";
reports[28] = "/Archives/edgar/data/320193/000119312512444068/R29.htm";
reports[29] = "/Archives/edgar/data/320193/000119312512444068/R30.htm";
reports[30] = "/Archives/edgar/data/320193/000119312512444068/R31.htm";
reports[31] = "/Archives/edgar/data/320193/000119312512444068/R32.htm";
reports[32] = "/Archives/edgar/data/320193/000119312512444068/R33.htm";
reports[33] = "/Archives/edgar/data/320193/000119312512444068/R34.htm";
reports[34] = "/Archives/edgar/data/320193/000119312512444068/R35.htm";
reports[35] = "/Archives/edgar/data/320193/000119312512444068/R36.htm";
reports[36] = "/Archives/edgar/data/320193/000119312512444068/R37.htm";
reports[37] = "/Archives/edgar/data/320193/000119312512444068/R38.htm";
reports[38] = "/Archives/edgar/data/320193/000119312512444068/R39.htm";
reports[39] = "/Archives/edgar/data/320193/000119312512444068/R40.htm";
reports[40] = "/Archives/edgar/data/320193/000119312512444068/R41.htm";
reports[41] = "/Archives/edgar/data/320193/000119312512444068/R42.htm";
reports[42] = "/Archives/edgar/data/320193/000119312512444068/R43.htm";
reports[43] = "/Archives/edgar/data/320193/000119312512444068/R44.htm";
reports[44] = "/Archives/edgar/data/320193/000119312512444068/R45.htm";
reports[45] = "/Archives/edgar/data/320193/000119312512444068/R46.htm";
reports[46] = "/Archives/edgar/data/320193/000119312512444068/R47.htm";
reports[47] = "/Archives/edgar/data/320193/000119312512444068/R48.htm";
reports[48] = "/Archives/edgar/data/320193/000119312512444068/R49.htm";
reports[49] = "/Archives/edgar/data/320193/000119312512444068/R50.htm";
reports[50] = "/Archives/edgar/data/320193/000119312512444068/R51.htm";
reports[51] = "/Archives/edgar/data/320193/000119312512444068/R52.htm";
reports[52] = "/Archives/edgar/data/320193/000119312512444068/R53.htm";
reports[53] = "/Archives/edgar/data/320193/000119312512444068/R54.htm";
reports[54] = "/Archives/edgar/data/320193/000119312512444068/R55.htm";
reports[55] = "/Archives/edgar/data/320193/000119312512444068/R56.htm";
reports[56] = "/Archives/edgar/data/320193/000119312512444068/R57.htm";
reports[57] = "/Archives/edgar/data/320193/000119312512444068/R58.htm";
reports[58] = "/Archives/edgar/data/320193/000119312512444068/R59.htm";
reports[59] = "/Archives/edgar/data/320193/000119312512444068/R60.htm";
reports[60] = 'all';

Dictionary stopping at loadingfromscreen

I run the code and it will not store the values it stops immediately at the loadingfromscreen. What its supposed to do is a multi-page application form that will reinput the values to the texbox's on the back button from the next form.
The ASP.net code is too long to post, but basically its just texbox's and dropboxes. If needed i can post it, but the main issue im 90% sure is the C# code.
UPDATE: When i say stop it continues the code but will not run the dictionary method...i have put a arrow where the method stops in DICTIONARY ONLY
C#:
public partial class employment_driversapplication_personalinfo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Dictionary<string, string> DriversApplicationData = (Dictionary<string, string>) Session["DriversApp"];
try
{
if (Page.IsPostBack)
{
LoadMemoryFromScreen(DriversApplicationData);
}
else
{
LoadScreenFromMemory(DriversApplicationData);
}
}
catch //(Exception ex)
{
// throw new Exception("Exception occured in employment_driversapplication_personalinfo.aspx - Page_Load" + ex.Message);
}
finally
{
}
}
private void LoadMemoryFromScreen(Dictionary<string, string> DicDriversApp)
{
DicDriversApp["position"] = position.Text; <---Stops here (won't even store this)
DicDriversApp["fname"] = fname.Text;
DicDriversApp["middleinitial"] = middleinitial.Text;
DicDriversApp["lname"] = lname.Text;
DicDriversApp["birthday"] = birthday.Text;
DicDriversApp["proofofage"] = proofofage.SelectedValue;
DicDriversApp["address"] = address.Text;
DicDriversApp["city"] = city.Text;
DicDriversApp["state"] = state.Text;
DicDriversApp["email"] = email.Text;
DicDriversApp["phone"] = phone.Text;
DicDriversApp["altphone"] = altphone.Text;
DicDriversApp["citizen"] = citizen.SelectedValue;
DicDriversApp["whoreferred"] = whoreferred.Text;
DicDriversApp["famfriend"] = famfriend.Text;
DicDriversApp["relationship"] = relationship.Text;
DicDriversApp["rateofpayexpected"] = rateofpayexpected.Text;
DicDriversApp["rateofpaytype"] = RadioButtonList1.SelectedValue;
DicDriversApp["employedNow"] = employednow.SelectedValue;
DicDriversApp["curremployment"] = curremployment.Text;
DicDriversApp["pastAddress"] = pastaddress.SelectedValue;
DicDriversApp["previousAddress"] = previousaddress.Text;
DicDriversApp["previousCity"] = previouscity.Text;
DicDriversApp["previousZip"] = previouszip.Text;
DicDriversApp["previousState"] = previousstate.Text;
DicDriversApp["previousDuration"] = previousduration.Text;
DicDriversApp["previousAddress1"] = previousaddress1.Text;
DicDriversApp["previousCity1"] = previouscity1.Text;
DicDriversApp["previousZip1"] = previouszip1.Text;
DicDriversApp["previousState1"] = previousstate1.Text;
DicDriversApp["previousDuration1"] = previousduration1.Text;
Session["DriversApp"] = DicDriversApp;
}
private void LoadScreenFromMemory(Dictionary<string, string> DicDriversApp)
{
position.Text = DicDriversApp["position"];
fname.Text = DicDriversApp["fname"] ;
middleinitial.Text = DicDriversApp["middleinitial"];
lname.Text = DicDriversApp["lname"];
birthday.Text = DicDriversApp["birthday"];
proofofage.SelectedValue = DicDriversApp["proofofage"];
address.Text = DicDriversApp["address"];
city.Text = DicDriversApp["city"];
state.Text = DicDriversApp["state"];
email.Text = DicDriversApp["email"];
phone.Text = DicDriversApp["phone"];
altphone.Text = DicDriversApp["altphone"];
citizen.SelectedValue = DicDriversApp["citizen"];
whoreferred.Text = DicDriversApp["whoreferred"];
famfriend.Text = DicDriversApp["famfriend"];
relationship.Text = DicDriversApp["relationship"];
rateofpayexpected.Text = DicDriversApp["rateofpayexpected"];
RadioButtonList1.SelectedValue = DicDriversApp["rateofpaytype"];
employednow.SelectedValue = DicDriversApp["employedNow"];
curremployment.Text = DicDriversApp["curremployment"];
pastaddress.SelectedValue = DicDriversApp["pastAddress"];
previousaddress.Text = DicDriversApp["previousAddress"];
previouscity.Text = DicDriversApp["previousCity"];
previouszip.Text = DicDriversApp["previousZip"];
previousstate.Text = DicDriversApp["previousState"];
previousduration.Text = DicDriversApp["previousDuration"];
previousaddress1.Text = DicDriversApp["previousAddress1"];
previouscity1.Text = DicDriversApp["previousCity1"];
previouszip1.Text = DicDriversApp["previousZip1"];
previousstate1.Text = DicDriversApp["previousState1"];
previousduration1.Text = DicDriversApp["previousDuration1"];
}
try something like this:
private void LoadMemoryFromScreen()
{
Dictionary<string, string> driver = new Dictionary<string, string>();
driver.Add("position", position.Text);
driver.Add("othervalue",value.Text); ///etc..
Session["dict"] = driver;
}
then, later on if you want to access the values in your dictionary, use something like this:
var dict = (Dictionary<string, string>)Session["dict"];
problem with this is that you're going to have to use dict.GetElementAt(index) in order to retrieve values, and i don't think that's a very good approach.
This will work, but i kinda dont understand why you are using a dictionary to do this. I assume you are only loading data from 1 person on your page? Then you might as well just make a class with all the properties in it, and then you can just pass that around instead of using this dictionary/session hack.
public class DriversApplicationData
{
public string position {get;set;}
public string firstname {get;set;}
//etc
}
then, you can just do something like
DriversApplicationData data = new DriversApplicationData();
data.position = position.Text;
data.firstname = fname.Text;
this is gonna be alot easier to maintain and to retrieve/insert values.

Categories