Example #1
0
        public ActionResult PetAlert(PetAlertViewModel model)
        {
            if (!model.Latitude.HasValue && !model.Longitude.HasValue)
            {
                this.SetAlertMessageInTempData(AlertMessageTypeEnum.Error, "Su ubicacion no puede ser determinada.");
                return(RedirectToAction("PetAlert", new { id = model.PetCode }));
            }

            this.VerifySessionVariables();

            model.OwnerId      = this.GetSessionOwnerId();
            model.Type         = (int)AlertTypeEnum.Lost;
            model.StaticMapUrl = SaveStaticGoogleMap(model.StaticMapUrl);

            try
            {
                var petAlert = _ownerDataLoader.AddPetAlert(model);
                this.SetAlertMessageInTempData(AlertMessageTypeEnum.Success, "La alerta ha sido guardada.");
            }
            catch (Exception ex)
            {
                this.SetAlertMessageInTempData(AlertMessageTypeEnum.Error, ex.Message);
            }

            return(RedirectToAction("Index"));
        }
Example #2
0
        public ActionResult PetAlert(string id)
        {
            this.VerifySessionVariables();

            var pet       = _petDataLoader.GetPetByCode(id);
            var lastAlert = pet.Alerts.OrderByDescending(a => a.CreatedOn).FirstOrDefault();

            SetPetProfileNavBarInfo(pet, "PetAlert");
            var model = new PetAlertViewModel()
            {
                PetCode = id
            };

            this.SetAlertMessageInViewBag();

            if (lastAlert != null)
            {
                if (lastAlert.Status == (int)AlertStatusEnum.Active)
                {
                    return(View("PetFound", model));
                }
                else if (lastAlert.Status == (int)AlertStatusEnum.Reported)
                {
                    return(View("PetAlertReported"));
                }
            }

            return(View(model));
        }
Example #3
0
        public PetAlert FoundPet(PetAlertViewModel model)
        {
            var request = new PetAlertFoundRequest
            {
                OwnerId      = model.OwnerId,
                PetCode      = Guid.Parse(model.PetCode),
                Comment      = HttpUtility.HtmlEncode(model.Commets),
                MakeItPublic = model.MakeItPublic
            };

            var response = _findMyPetClient.JsonClient().Put(request);

            return(response);
        }
Example #4
0
        public PetAlert AddPetAlert(PetAlertViewModel model)
        {
            var request = new PetAlertCreateRequest
            {
                OwnerId          = model.OwnerId,
                PetCode          = Guid.Parse(model.PetCode),
                Latitude         = model.Latitude.Value,
                Longitude        = model.Longitude.Value,
                Comment          = HttpUtility.HtmlEncode(model.Commets),
                PositionImageUrl = model.StaticMapUrl,
                Type             = model.Type
            };

            var response = _findMyPetClient.JsonClient().Post(request);

            return(response);
        }
Example #5
0
        public ActionResult PetFound(string id, PetAlertViewModel model)
        {
            this.VerifySessionVariables();

            model.OwnerId = this.GetSessionOwnerId();
            model.PetCode = id;

            try
            {
                var petAlert = _ownerDataLoader.FoundPet(model);
                this.SetAlertMessageInTempData(AlertMessageTypeEnum.Success, "Nos alegra que haya encontrado a su Mascota!!!");
            }
            catch (Exception ex)
            {
                this.SetAlertMessageInTempData(AlertMessageTypeEnum.Error, ex.Message);
            }

            return(RedirectToAction("Index"));
        }
 public PetAlert FoundPet(PetAlertViewModel model)
 {
     return(_ownerServiceClient.FoundPet(model));
 }
 public PetAlert AddPetAlert(PetAlertViewModel model)
 {
     return(_ownerServiceClient.AddPetAlert(model));
 }