public virtual ActionResult Locate(EstablishmentForm model)
 {
     if (model != null)
     {
         var establishment = _queryProcessor.Execute(new EstablishmentByGuid(model.EntityId)
         {
             EagerLoad = new Expression<Func<Establishment, object>>[]
             {
                 e => e.Location,
             }
         });
         if (establishment != null)
         {
             var command = new UpdateEstablishment
             {
                 Id = establishment.RevisionId,
                 GoogleMapZoomLevel = model.Location.GoogleMapZoomLevel,
                 CenterLatitude = model.Location.CenterLatitude,
                 CenterLongitude = model.Location.CenterLongitude,
                 NorthLatitude = model.Location.BoundingBoxNortheastLatitude,
                 EastLongitude = model.Location.BoundingBoxNortheastLongitude,
                 SouthLatitude = model.Location.BoundingBoxSouthwestLatitude,
                 WestLongitude = model.Location.BoundingBoxSouthwestLongitude,
             };
             var oldCenter = establishment.Location.Center;
             //establishment.Location.GoogleMapZoomLevel = model.Location.GoogleMapZoomLevel;
             //establishment.Location.Center = new Coordinates
             //{
             //    Latitude = model.Location.CenterLatitude,
             //    Longitude = model.Location.CenterLongitude
             //};
             //establishment.Location.BoundingBox = new BoundingBox
             //{
             //    Northeast = new Coordinates
             //    {
             //        Latitude = model.Location.BoundingBoxNortheastLatitude,
             //        Longitude = model.Location.BoundingBoxNortheastLongitude,
             //    },
             //    Southwest = new Coordinates
             //    {
             //        Latitude = model.Location.BoundingBoxSouthwestLatitude,
             //        Longitude = model.Location.BoundingBoxSouthwestLongitude,
             //    },
             //};
             //_establishments.UnitOfWork.SaveChanges();
             //_objectCommander.Update(establishment, true);
             //_entities.Update(establishment);
             _updateEstablishment.Handle(command);
             _unitOfWork.SaveChanges();
             if (!oldCenter.HasValue)
             {
                 var builder = new SupplementalLocationPlacesBuilder(establishment.RevisionId);
                 var thread = new Thread(builder.Build);
                 thread.Start();
             }
             SetFeedbackMessage(string.Format("Successfully located {0}", establishment.TranslatedName));
             return Redirect(string.Format("/{0}", model.ReturnUrl));
         }
     }
     return HttpNotFound();
 }
Exemplo n.º 2
0
 public virtual ActionResult Locate(EstablishmentForm model)
 {
     if (model != null)
     {
         var establishment = _queryProcessor.Execute(new EstablishmentByGuid(model.EntityId)
         {
             EagerLoad = new Expression <Func <Establishment, object> >[]
             {
                 e => e.Location,
             }
         });
         if (establishment != null)
         {
             var command = new UpdateEstablishment
             {
                 Id = establishment.RevisionId,
                 GoogleMapZoomLevel = model.Location.GoogleMapZoomLevel,
                 CenterLatitude     = model.Location.CenterLatitude,
                 CenterLongitude    = model.Location.CenterLongitude,
                 NorthLatitude      = model.Location.BoundingBoxNortheastLatitude,
                 EastLongitude      = model.Location.BoundingBoxNortheastLongitude,
                 SouthLatitude      = model.Location.BoundingBoxSouthwestLatitude,
                 WestLongitude      = model.Location.BoundingBoxSouthwestLongitude,
             };
             var oldCenter = establishment.Location.Center;
             //establishment.Location.GoogleMapZoomLevel = model.Location.GoogleMapZoomLevel;
             //establishment.Location.Center = new Coordinates
             //{
             //    Latitude = model.Location.CenterLatitude,
             //    Longitude = model.Location.CenterLongitude
             //};
             //establishment.Location.BoundingBox = new BoundingBox
             //{
             //    Northeast = new Coordinates
             //    {
             //        Latitude = model.Location.BoundingBoxNortheastLatitude,
             //        Longitude = model.Location.BoundingBoxNortheastLongitude,
             //    },
             //    Southwest = new Coordinates
             //    {
             //        Latitude = model.Location.BoundingBoxSouthwestLatitude,
             //        Longitude = model.Location.BoundingBoxSouthwestLongitude,
             //    },
             //};
             //_establishments.UnitOfWork.SaveChanges();
             //_objectCommander.Update(establishment, true);
             //_entities.Update(establishment);
             _updateEstablishment.Handle(command);
             _unitOfWork.SaveChanges();
             if (!oldCenter.HasValue)
             {
                 var builder = new SupplementalLocationPlacesBuilder(establishment.RevisionId);
                 var thread  = new Thread(builder.Build);
                 thread.Start();
             }
             SetFeedbackMessage(string.Format("Successfully located {0}", establishment.TranslatedName));
             return(Redirect(string.Format("/{0}", model.ReturnUrl)));
         }
     }
     return(HttpNotFound());
 }