private void KuRZY_Detach(Kurzy entity) { entity.Autoskoly = null; }
private void KuRZY_Attach(Kurzy entity) { entity.Autoskoly = this; }
private void KuRZY_Detach(Kurzy entity) { entity.TypyKurzu = null; }
private void KuRZY_Attach(Kurzy entity) { entity.TypyKurzu = this; }
private void importKurzy(JObject importFile, DrivingScoolContext db, uint autoskola_id) { var vo = importFile["KURZY"].Children(); List<Kurzy> importedKurzy = new List<Kurzy>(); foreach (var o in vo) { Kurzy k = new Kurzy() { IdentifikacniCislo = "0000000", Typ = o.Value<string>("typ"), AutoskolaID = autoskola_id, Stav = o.Value<string>("stav"), DatumOd = o.Value<DateTime>("datum_od"), DatumDo = o.Value<DateTime>("datum_do") }; importedKurzy.Add(k); db.Kurzy.InsertOnSubmit(k); } db.SubmitChanges(); foreach (var k in importedKurzy) { k.IdentifikacniCislo = k.Typ + k.DatumOd.Year + (k.KurzID % 100).ToString("D2"); } db.SubmitChanges(); }
public JObject Post(JObject o) { Kurzy k; using (var db = DrivingScoolContextHelper.CreateDataContext2()) { try { db.Kurzy.InsertOnSubmit(k = new Kurzy() { IdentifikacniCislo = "0000000", Typ = o.Value<string>("typ"), AutoskolaID = o.Value<uint>("autoskola_id"), Stav = o.Value<string>("stav"), DatumOd = o.Value<DateTime>("datum_od"), DatumDo = o.Value<DateTime>("datum_do") }); db.SubmitChanges(); k.IdentifikacniCislo = k.Typ + k.DatumOd.Year + (k.KurzID%100).ToString("D2"); db.SubmitChanges(); } catch (AggregateException) { throw new HttpResponseException(HttpStatusCode.InternalServerError); } } return Get(null, (int?)k.KurzID); }