public ActionResult EditModesAddNewPartial(Location product) { if (ModelState.IsValid) { try { //NorthwindDataProvider.InsertProduct(product); using (var data = new Provider()) { data.LocationRepository.Add(product); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } else ViewData["EditError"] = "Please, correct all errors."; using (var data = new Provider()) { return PartialView("EditLocationsPartial", data.LocationRepository.GetAllLocation()); } //return PartialView("EditModesPartial", NorthwindDataProvider.GetEditableProducts()); }
public void Update(Location newLocation) { using (ISession session = NHibernateHelper.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { session.Update(newLocation); transaction.Commit(); } } }
public void Delete(Location newLocation) { using (ISession session = NHibernateHelper.OpenSession()) { using (ITransaction transaction = session.BeginTransaction()) { using(var data = new GeoWPFCreateDbTest.BL.Provider.Provider()) { var carsForDelete = data.CarRepository.GetCarsByLocationId(newLocation.Id); data.CarRepository.DeleteCarByCollection(carsForDelete); } session.Delete(newLocation); transaction.Commit(); } } }
public ActionResult EditModesDeletePartial(Location productID) { if (productID.Id >= 0) { try { //NorthwindDataProvider.DeleteProduct(productID); using (var data = new Provider()) { var product = data.LocationRepository.GetLocationById(((Location)productID).Id); data.LocationRepository.Delete(product); } } catch (Exception e) { ViewData["EditError"] = e.Message; } } //return PartialView("EditModesPartial", NorthwindDataProvider.GetEditableProducts()); using (var data = new Provider()) { return PartialView("EditLocationsPartial", data.LocationRepository.GetAllLocation()); } }