/// <summary> /// Adds a place to the cache or returns validation errors /// </summary> public ValidationServiceResponse <CartoPlaceInfo> CreatePlace(CartoPlaceCreateRequest create) { if (!String.IsNullOrWhiteSpace(create.PlaceKey)) { throw new Exception($"CreatePlace request should not have PlaceKey {create.PlaceKey} set!"); } var validate = ValidatePlace(create); if (validate.OK) { create.PlaceKey = Graffiti.Crypto.GetNewHash(); _cache.Add(validate.Data); _dirty = true; } return(validate); }
public ActionResult Create(CartoPlaceCreateRequest request) { // TODO: do validation var response = _cartoPlaceService.CreatePlace(request); if (response.OK) { return(Redirect(PlaceViewModel.GetDisplayUrl(response.Data.Key))); } else { // show validation error messages var model = InitModel(); model.SelectedPlace = response.Data; model.Edit = new CartoPlaceFormModel(response.Data, request); model.AddValidationErrors(response.ValidationErrors); return(View("Create", model)); } }