public PetAlert AddPetPublicAlert(PetPublicAlertViewModel model, List <string> urlImages) { var request = new PetAlertCreateRequest { OwnerId = model.OwnerId, Latitude = model.Latitude.Value, Longitude = model.Longitude.Value, Comment = HttpUtility.HtmlEncode(model.Commets), PositionImageUrl = model.StaticMapUrl, Type = model.SelectedAlertTypeId, UrlImages = urlImages }; var response = _findMyPetClient.JsonClient().Post(request); return(response); }
public ActionResult Alert() { this.VerifySessionVariables(); var model = new PetPublicAlertViewModel { AlertTypes = GetAlertTypes() }; if (Request.IsAuthenticated) { model.OwnerId = this.GetSessionOwnerId(); } this.SetAlertMessageInViewBag(); return(View(model)); }
public ActionResult Alert(PetPublicAlertViewModel model) { //return Content("Error From Google ReCaptcha : " + response.ErrorMessage[0].ToString()); if (!Request.IsAuthenticated) { CaptchaResponse response = CaptchaHelper.ValidateCaptcha(Request["g-recaptcha-response"]); if (!response.Success) { return(RedirectToAction("CaptchaInvalid")); } } if (!ModelState.IsValid) { return(View(model)); } if (!model.Latitude.HasValue && !model.Longitude.HasValue) { this.SetAlertMessageInTempData(AlertMessageTypeEnum.Error, "Su ubicacion no puede ser determinada."); return(RedirectToAction("Alert")); } this.VerifySessionVariables(); if (User.Identity.IsAuthenticated) { model.OwnerId = this.GetSessionOwnerId(); } try { var files = model.Images.ToList(); if (files.Count > 0) { if (!ValidFileExtensions(files)) { this.SetAlertMessageInTempData(AlertMessageTypeEnum.Error, "Solo estan permitidos archivos .jpg y .png"); return(RedirectToAction("Alert")); } else { var urlImages = new List <string>(); model.StaticMapUrl = SaveStaticGoogleMap(model.StaticMapUrl); foreach (var file in files) { var newImageFilePath = this.ResizeAndSaveImage(file); urlImages.Add(newImageFilePath); } //try //{ var petAlert = _ownerDataLoader.AddPetPublicAlert(model, urlImages); this.SetAlertMessageInTempData(AlertMessageTypeEnum.Success, "La alerta ha sido guardada."); //} //catch (Exception ex) //{ // this.SetAlertMessageInTempData(AlertMessageTypeEnum.Error, ex.Message); //} } } } catch (Exception ex) { this.SetAlertMessageInTempData(AlertMessageTypeEnum.Error, "Hubo un error en el proceso."); } return(RedirectToAction("Alert")); }
public PetAlert AddPetPublicAlert(PetPublicAlertViewModel model, List <string> urlImages) { return(_ownerServiceClient.AddPetPublicAlert(model, urlImages)); }