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)); }
public ActionResult Home() { ViewBag.Page = page.setView("Home").setTitle("NEW WORLD"); ViewBag.Message = TempData["Message"]; List <PlaceDTO> placeDTO = PlaceService.GetAll().OrderByDescending(x => x.Rating).ToList(); List <QuestDTO> questDTO = QuestServices.GetAll().OrderByDescending(x => x.StartQuest).ThenBy(x => x.countPeople).ThenBy(x => x.Name).ToList(); ViewBag.placeDTO = placeDTO; ViewBag.questDTO = questDTO; return(View()); }
public IActionResult Get() { try { return(Ok(Mapper.Map <IEnumerable <PlaceViewModel> >(_placeService.GetAll()))); } catch (Exception ex) { _logger.LogError("Could not get all places!", ex); return(BadRequest("Error occurred")); } }
public JsonResult SearchLines() { string Search = Request.Form["Search"]; List <PlaceDTO> places = PlaceService.GetAll(); List <SearchLine> blocks = new List <SearchLine>(); blocks.AddRange(places.Where(x => x.Name.ToLower().Contains(Search.ToLower())) .OrderBy(x => x.Name).Select(x => new SearchLine() { Type = x.Tags, Value = x.Name })); blocks.AddRange(places.Where(x => x.Tags.ToLower().Contains(Search.ToLower())) .OrderBy(x => x.Tags).Select(x => new SearchLine() { Type = "Тег", Value = x.Tags })); return(Json(blocks)); }
public IActionResult GetAll(SearchModel model) { model = _service.GetAll(model); return(View("Index", model)); }
public ActionResult AddPlace(HttpPostedFileBase[] Photo) { string Name = Request.Form["Name"]; string Address = Request.Form["Address"]; string Site = Request.Form["Site"]; string Phone = Request.Form["Phone"]; string Description = Request.Form["Description"]; string Coordinates = Request.Form["Coordinates"]; var re = new Regex(@"[\[\]]"); double[] NewCoordinates = re.Replace(Coordinates, "").Split(',') .Select(x => Convert.ToDouble(x.Replace(".", ","))).ToArray(); string Tags = Request.Form["Tags"]; DateTime DateCreate = DateTime.Now; if (Name != "" && Address != "" && NewCoordinates.Length == 2 && Identity.isAuthentication) { PlaceDTO placeDTO = new PlaceDTO(); placeDTO.Address = Address; placeDTO.Creater = Identity.user.Id; placeDTO.Longitude = NewCoordinates[0]; placeDTO.Latitude = NewCoordinates[1]; placeDTO.DateCreate = DateCreate; placeDTO.Description = Description; placeDTO.Name = Name; placeDTO.Tags = Tags;; placeDTO.Site = Site; placeDTO.Phone = Phone; PlaceService.Create(placeDTO); PlaceDTO newPlace = PlaceService.GetAll().FirstOrDefault(x => x.Name == Name && x.Creater == Identity.user.Id && x.DateCreate == DateCreate); PlacePhotoDTO placePhoto; string dir = Server.MapPath("~/Resources/Images/Places/" + newPlace.Id); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } if (Photo.Count() > 0) { foreach (HttpPostedFileBase photo in Photo) { string type = photo.FileName.Split('.').Last(); string[] dirs = Directory.GetFiles(Server.MapPath("~/Resources/Images/Places/" + newPlace.Id), "*"); string src = "/Resources/Images/Places/" + newPlace.Id + "/" + cryptMD5.GetHash(dirs.Length.ToString()) + "." + type; string path = Server.MapPath("~" + src); photo.SaveAs(path); placePhoto = new PlacePhotoDTO(); placePhoto.Main = false; placePhoto.SRC = src; placePhoto.PlaceId = newPlace.Id; PlacePhotoServices.Create(placePhoto); } placePhoto = PlacePhotoServices.GetAll().FirstOrDefault(x => x.Main == false && x.PlaceId == newPlace.Id); if (placePhoto != null) { placePhoto.Main = true; PlacePhotoServices.Update(placePhoto); } } } return(RedirectToAction("Place")); }