public async Task <IActionResult> Create(PlaceCreateModel model) { var user = await _userManager.GetUserAsync(User); await _service.Create(model, user.Id); return(RedirectToAction("GetAll")); }
public ActionResult <dynamic> Create(Place pPlace) { dynamic result = _placeService.Create(pPlace); if (result.status < 0) { return(StatusCode(StatusCodes.Status409Conflict)); } return(result); }
public ActionResult <Place> Create(Place place) { _placeService.Create(place); return(CreatedAtRoute("GetPlace", new { id = place.Id.ToString() }, place)); }
public async Task Post(CreatePlaceRequest request) { await places.Create(request.GetDto()); }
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")); }