public void FormView2_InsertItem(Record record) { if (ModelState.IsValid) { try { record.RecordTypeID = 2; Service.SaveRecord(record); var digrecord = new DigitalRecord { RecordID = record.RecordID, DiscSize = ((TextBox)FormView2.FindControl("DiscSizeTextBox")).Text }; Service.SaveDigitalRecord(digrecord); RecordID = record.RecordID; Response.RedirectToRoute("RecordDetails", new { id = digrecord.RecordID }); Context.ApplicationInstance.CompleteRequest(); } catch (Exception) { ModelState.AddModelError(String.Empty, "Ett fel inträffade då skivan skulle sparas"); } } }
public void FormView1_InsertItem(Record record) { if (ModelState.IsValid) { try { record.RecordTypeID = 1; Service.SaveRecord(record); var pricevalue = ((TextBox)FormView1.FindControl("PriceTextBox")).Text; //TODO fixa så det funkar utan InvariantCulture //CultureInfo.InvariantCulture var Price = decimal.Parse(pricevalue); var Purchasedate = DateTime.Parse(((TextBox)FormView1.FindControl("PurchaseDateTextBox")).Text); var physrecord = new PhysicalRecord { RecordID = record.RecordID, PriceAtPurchase = Price, DateofPurchase = Purchasedate }; Service.SavePhysicalRecord(physrecord); RecordID = record.RecordID; Response.RedirectToRoute("RecordDetails", new { id = physrecord.RecordID }); Context.ApplicationInstance.CompleteRequest(); } catch (Exception) { ModelState.AddModelError(String.Empty, "Ett fel inträffade då skivan skulle sparas"); } } }