Пример #1
0
        public void PlaceServiceGet_PlaceId_ReturnsPlaceDto()
        {
            // Arrange
            int placeId = 1;

            //var mapperMock = new Mock<IMappingAction<Place,PlaceDto>>();
            //var mapperMock2 = new Mock<IObjectMapper>();
            //var mapperMock2 = new Mock<IMapper>();
            //    mapperMock2.Setup(m => m.Map<Place, PlaceDto>(It.IsAny<Place>())).Returns(new PlaceDto());


            var uowMock = new Mock <IUnitOfWork>();

            uowMock.Setup(u => u.Places.Add(new Place {
                Id = 1, Name = "Kharkiv railway station"
            }));
            uowMock.Setup(u => u.Places.Get(placeId)).Returns(new Place {
                Name = "Kharkiv railway station"
            });

            var placeService = new PlaceService(uowMock.Object);


            // Act
            var placeDto = placeService.Get(placeId);

            // Assert
            //Assert.IsNotNull(placeDto);
            //uowMock.Verify(a => a.Places.Get(placeId), Times.Exactly(2));
            Assert.AreEqual("Kharkiv railway station", placeDto.Name);
        }
Пример #2
0
 private async Task DeleteItemsAsync(IEnumerable <PlaceModel> models)
 {
     foreach (var model in models)
     {
         await PlaceService.DeletePlaceAsync(model);
     }
 }
Пример #3
0
        public async Task LoadAsync(PlaceDetailsArgs args)
        {
            ViewModelArgs = args ?? PlaceDetailsArgs.CreateDefault();

            if (ViewModelArgs.IsNew)
            {
                Item = new PlaceModel();
                Item = await PlaceService.CreateNewPlaceAsync(ViewModelArgs.CustomerID);

                IsEditMode = true;
            }
            else
            {
                try
                {
                    var item = await PlaceService.GetPlaceAsync(ViewModelArgs.PlaceID);

                    Item = item ?? new PlaceModel {
                        PlaceID = ViewModelArgs.PlaceID, IsEmpty = true
                    };
                }
                catch (Exception ex)
                {
                    LogException("Place", "Load", ex);
                }
            }
        }
Пример #4
0
        private List <Entities.UserInRegion> GetListUserInRegion(int regionNum, Application2016.Areas.Admin.Models.ListUserInRegionModel listUir)
        {
            PlaceService placeService           = new PlaceService();
            List <Entities.UserInRegion> result = new List <Entities.UserInRegion>();

            Entities.UserInRegion uir;
            int[] arrCity     = listUir.region_city;
            int[] arrDistrict = listUir.region_district;
            int[] arrWard     = listUir.region_ward;
            for (int i = 0; i < regionNum; i++)
            {
                uir              = new UserInRegion();
                uir.ListCity     = placeService.ListPlaceItemByParent(0);
                uir.ListDistrict = new List <Item>();
                uir.ListWard     = new List <Item>();
                if (arrCity != null)
                {
                    uir.CityId     = arrCity[i];
                    uir.DistrictId = arrDistrict[i];
                    uir.WardId     = arrWard[i];
                    if (arrCity[i] > 0)
                    {
                        uir.ListDistrict = placeService.ListPlaceItemByParent(arrCity[i]);
                    }
                    if (arrDistrict[i] > 0)
                    {
                        uir.ListWard = placeService.ListPlaceItemByParent(arrDistrict[i]);
                    }
                }

                result.Add(uir);
            }
            return(result);
        }
Пример #5
0
        public JsonResult ListPlaceByRegion(int regionId)
        {
            PlaceService         placeService = new PlaceService();
            List <Entities.Item> lstEntity    = placeService.ListPlaceItemOfRegion(regionId);

            return(Json(lstEntity));
        }
Пример #6
0
        public JsonResult ListPlaceByRegions(int[] regionIds)
        {
            PlaceService         placeService = new PlaceService();
            List <Entities.Item> allEntity    = new List <Entities.Item>();

            if (regionIds != null)
            {
                List <Entities.Item> lstEntity;
                foreach (int regionId in regionIds)
                {
                    lstEntity = placeService.ListPlaceItemOfRegion(regionId);
                    if (lstEntity.Count > 0)
                    {
                        allEntity.AddRange(lstEntity);
                    }
                }
                allEntity.Insert(0, new Entities.Item()
                {
                    Id = 0, Text = ""
                });
                return(Json(allEntity));
            }

            return(Json(allEntity));
        }
Пример #7
0
        public ActionResult EditPlace(ParkingPlace aPlace)
        {
            PlaceService service = new PlaceService();

            service.editPlace(aPlace, 10);
            return(RedirectToAction("index", "Owner"));
        }
Пример #8
0
        /// <summary>
        /// Maps the services.
        /// </summary>
        /// <param name="csdServices">The CSD services.</param>
        /// <returns>Returns a list of place services.</returns>
        private static IEnumerable <PlaceService> MapServices(IEnumerable <service> csdServices)
        {
            // TODO: implement
            return(new List <PlaceService>());

            var placeServiceService = ApplicationContext.Current.GetService <IDataPersistenceService <PlaceService> >();
            var services            = new List <PlaceService>();

            foreach (var csdService in csdServices)
            {
                var service = new PlaceService();

                Guid key;

                //service.Key = !TryMapKey(csdService.entityID, out key) ? Guid.NewGuid() : key;

                // map service concept
                if (csdService.codedType?.Any() == true)
                {
                    // we don't support multiple service types for a place service at the moment, so we only take the first one
                    service.ServiceConceptKey = MapCodedType(csdService.codedType[0].code, csdService.codedType[0].codingScheme)?.Key;
                }

                services.Add(service);
            }

            return(services);
        }
Пример #9
0
        public async Task <List <Tracking_PlaceDTO> > FilterListPlace([FromBody] Tracking_PlaceFilterDTO Tracking_PlaceFilterDTO)
        {
            if (!ModelState.IsValid)
            {
                throw new BindException(ModelState);
            }

            PlaceFilter PlaceFilter = new PlaceFilter();

            PlaceFilter.Skip         = 0;
            PlaceFilter.Take         = 20;
            PlaceFilter.OrderBy      = PlaceOrder.Id;
            PlaceFilter.OrderType    = OrderType.ASC;
            PlaceFilter.Selects      = PlaceSelect.ALL;
            PlaceFilter.Id           = Tracking_PlaceFilterDTO.Id;
            PlaceFilter.Name         = Tracking_PlaceFilterDTO.Name;
            PlaceFilter.PlaceGroupId = Tracking_PlaceFilterDTO.PlaceGroupId;
            PlaceFilter.Radius       = Tracking_PlaceFilterDTO.Radius;
            PlaceFilter.Latitude     = Tracking_PlaceFilterDTO.Latitude;
            PlaceFilter.Longtitude   = Tracking_PlaceFilterDTO.Longtitude;

            List <Place> Places = await PlaceService.List(PlaceFilter);

            List <Tracking_PlaceDTO> Tracking_PlaceDTOs = Places
                                                          .Select(x => new Tracking_PlaceDTO(x)).ToList();

            return(Tracking_PlaceDTOs);
        }
Пример #10
0
        public PartialViewResult Update(int id = 0, int cityId = -1, int districtId = -1, int wardId = -1, int regionId = -1)
        {
            PlaceService  placeService  = new PlaceService();
            RegionService regionService = new RegionService();

            Models.Road_VillageModel m = new Models.Road_VillageModel();
            if (id > 0)
            {
                var road = roadService.GetById(id);
                m.MapFrom(road, ref m);
                m.DistrictId = placeService.GetParentItem(m.WardId).Id;
                m.CityId     = placeService.GetParentItem(m.DistrictId).Id;
                cityId       = m.CityId;
                districtId   = m.DistrictId;
                wardId       = m.WardId;
            }

            m.ListCity     = placeService.ListPlaceItemByParent(0);
            m.ListDistrict = placeService.ListPlaceItemByParent(cityId);
            m.ListWard     = placeService.ListPlaceItemByParent(districtId);
            m.ListRegion   = regionService.List();

            LoadData();

            ViewBag.ListRoad   = roadService.ListItem(wardId, regionId);
            ViewBag.ActionForm = "Update";
            return(PartialView("index", m));
        }
Пример #11
0
        public ActionResult Delete(int id)
        {
            PlaceService service = new PlaceService();

            service.deletePlace(id);
            return(RedirectToAction("index", "Owner"));
        }
Пример #12
0
 public TalkController(TalkService talkService, SpeakerService speakerService, CityService cityService, PlaceService placeService, AuthenticationProvider authenticationProvider)
 {
     _talkService            = talkService;
     _speakerService         = speakerService;
     _cityService            = cityService;
     _placeService           = placeService;
     _authenticationProvider = authenticationProvider;
 }
Пример #13
0
        public string FindPlace()
        {
            var api = new PlaceService();

            var place = api.GetPlace("MacDonalds", "-23.5512625", "-46.8563475", "");

            return(place.Body);
        }
Пример #14
0
        private Place[] GetTopAvailabilited()
        {
            PlaceService placeService = new PlaceService();

            Place[] places = placeService.GetTopAvailabilited(10);

            return places;
        }
        public SendNotificationViewModel()
        {
            var temp = new SendNotification();

            temp.lstPlaces = PlaceService.GetPlaces();
            temp.Sent      = DateTime.Now;
            Notification   = temp;
        }
Пример #16
0
        private async Task DeleteRangesAsync(IEnumerable <IndexRange> ranges)
        {
            DataRequest <Place> request = BuildDataRequest();

            foreach (var range in ranges)
            {
                await PlaceService.DeletePlaceRangeAsync(range.Index, range.Length, request);
            }
        }
Пример #17
0
 private async Task <IList <PlaceModel> > GetItemsAsync()
 {
     if (!ViewModelArgs.IsEmpty)
     {
         DataRequest <Place> request = BuildDataRequest();
         return(await PlaceService.GetPlacesAsync(request));
     }
     return(new List <PlaceModel>());
 }
Пример #18
0
        private void PlaceComboBoxList() //Column 4
        {
            var Pla = PlaceService.GetCity().Select(x => x.Street);

            foreach (var pla in Pla)
            {
                PlaceComboBox.Items.Add(pla);
            }
        }
Пример #19
0
        public PlaceServiceTest()
        {
            var env = new Mock <IHostingEnvironment>();
            var projectRootDirectory = Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName).FullName;

            env.Setup(m => m.ContentRootPath).Returns(projectRootDirectory);
            IPlaceRepository = new DummyPlaceRepository(env.Object);
            IPlaceService    = new PlaceService(IPlaceRepository);
        }
Пример #20
0
        public string DbChk()
        {
            PlaceService        service = new PlaceService();
            List <ParkingPlace> data    = new List <ParkingPlace>();

            data = service.getMatchedPlaces("AIUB");

            return(data[0].SpotName.ToString());
        }
Пример #21
0
        private void PlaceComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            PlaceSetName.Text = PlaceService.GetPlace()
                                .Where(x => (x.Street == PlaceComboBox.SelectedItem.ToString()))
                                .Select(x => x.Street).FirstOrDefault().ToString();

            PlaceSetName.Text = PlaceService.GetPlace()
                                .Where(x => (x.Street == PlaceComboBox.SelectedItem.ToString()))
                                .Select(x => x.PlacePopulation).FirstOrDefault().ToString();
        }
Пример #22
0
        public ActionResult MakeRequest(Booking book)
        {
            book.UserId    = Convert.ToInt32(Session["USERID"]);
            book.IsPending = 1;

            PlaceService service = new PlaceService();

            service.RequestPlace(book);
            return(RedirectToAction("index", "Users"));
        }
Пример #23
0
        public ActionResult RegisterAgency2()
        {
            Application2016.Areas.Admin.Models.RegisterModel model = new Areas.Admin.Models.RegisterModel();
            PlaceService placeService = new PlaceService();

            // Lấy danh sách tỉnh.
            model.ListCity = placeService.ListPlaceItemByParent(0);

            return(PartialView("RegistryAgency2", model));
        }
Пример #24
0
        private async Task <IList <PlaceModel> > GetItems(string query)
        {
            var request = new DataRequest <Place>()
            {
                Query   = query,
                OrderBy = r => r.place_id
            };

            return(await PlaceService.GetPlacesAsync(0, 20, request));
        }
Пример #25
0
 public void InitLists()
 {
     SelectedTracks = new BindingList <Track>(NewStation.Tracks.ToList());
     Places         = new BindingList <Place>(PlaceService.GetAllPlaces());
     AllTracks      = new BindingList <Track>(TrackService.GetUnattachedTracks());
     if (NewStation.IsValid())
     {
         NewStation.Place = Places.First(x => x.Id == NewStation.Place.Id);//Necessary to init value in combo box properly
     }
 }
Пример #26
0
        private void PlaceComboBoxList() //Column 4
        {
            PlaceComboBox.Items.Clear();
            var Pla = PlaceService.GetPlace().Where(x => x.CityModel.Id == Id_City).Select(x => x.Street);

            foreach (var pla in Pla)
            {
                PlaceComboBox.Items.Add(pla);
            }
        }
Пример #27
0
        public JsonResult ListPlaceJson(int parentId)
        {
            PlaceService          placeService = new PlaceService();
            List <SelectListItem> lstEntity    = placeService.ListItem(parentId);

            lstEntity.Insert(0, new SelectListItem {
                Value = "0", Text = ""
            });
            return(Json(lstEntity));
        }
Пример #28
0
        public JsonResult SearchBlocks()
        {
            string Search = Request.Form["Search"];

            List <PlaceDTO> places = PlaceService.GetAll()
                                     .Where(x => x.Name.ToLower().Contains(Search.ToLower()) || x.Tags.ToLower().Contains(Search.ToLower()))
                                     .OrderBy(x => x.Name).ToList();

            return(Json(places));
        }
Пример #29
0
        public string getSearchItems(string id)
        {
            PlaceService        service = new PlaceService();
            List <ParkingPlace> matches = new List <ParkingPlace>();

            matches = service.getMatchedPlaces(id);
            var jsonSerialiser = new JavaScriptSerializer();
            var json           = jsonSerialiser.Serialize(matches);

            return(json);
        }
Пример #30
0
        public JsonResult ListPlaceJson(int parentId)
        {
            PlaceService         placeService = new PlaceService();
            List <Entities.Item> lstEntity    = placeService.ListPlaceItemByParent(parentId);

            lstEntity.Insert(0, new Entities.Item()
            {
                Id = 0, Text = ""
            });
            return(Json(lstEntity));
        }
        public PlaceControllerTest()
        {
            var hostingEnvironment   = new Mock <IHostingEnvironment>();
            var projectRootDirectory = Directory.GetParent(Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName).FullName;

            hostingEnvironment.Setup(m => m.ContentRootPath).Returns(projectRootDirectory);
            IPlaceRepository  = new DummyPlaceRepository(hostingEnvironment.Object);
            IPlaceService     = new PlaceService(IPlaceRepository);
            IModelTransformer = new ModelTransformer(hostingEnvironment.Object);
            PlaceController   = new PlaceController(IPlaceService, IModelTransformer);
        }
        public ActionResult Login(FormCollection formCollection)
        {
            AccountService accountService = new AccountService();

            Account auth = accountService.Authenticate(formCollection["user"], formCollection["pass"]);

            if (auth != null)
            {
                Session.Add("Account", auth);

                PlaceService placeService = new PlaceService();

                Place[] places = placeService.GetRatedPlaceByAccount(auth.AccountID);

                return View("~/Views/Account/Dashboard.cshtml", places);
            }

            return View();
        }
Пример #33
0
    public LocationEventArgs(PlaceService.TransitPlace place)
        : this(place.Country, place.State, place.City, place.Neighborhood)
    {

    }