public ActionResult AddDriver(IDriverInfo driverInfo) { PersonAccountDA account = GetPersonAccount(driverInfo); DriverAccountDA driverAccount = new DriverAccountDA { Person = account, PersonName = driverInfo.PersonName, CarBrand = driverInfo.CarBrand, CarColor = driverInfo.CarColor, CarNumber = driverInfo.CarNumber }; DriverInfoDA driver = new DriverInfoDA { PersonInfo = new PersonInfoDA { Latitude = driverInfo.CurrentLocationLatidude, Longitude = driverInfo.CurrentLocationLongidude, Person = account } }; _dataProxy.Session.Save(driver.PersonInfo); _dataProxy.Session.Save(driverAccount); _dataProxy.Session.Save(driver); return(ActionResult.ValidResult); }
public ActionResult RemoveDriver(IDriverInfo driverInfo) { DriverInfoDA data = _dataProxy.Session.CreateCriteria <DriverInfoDA>().List <DriverInfoDA>().FirstOrDefault(p => p.PersonInfo.Person.Id == driverInfo.Id); if (data == null) { return(ActionResult.GetErrorResult(new KeyNotFoundException())); } _dataProxy.Session.Delete(data); _dataProxy.Session.Delete(data.PersonInfo); return(ActionResult.ValidResult); }