Example #1
0
 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());
 }
Example #2
0
 public void Update(Location newLocation)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         using (ITransaction transaction = session.BeginTransaction())
         {
             session.Update(newLocation);
             transaction.Commit();
         }
     }
 }
Example #3
0
        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();
                }
            }
        }
Example #4
0
 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());
     }
 }