public ActionResult Vote()
        {
            var req = Request.InputStream;


            var userId = System.Web.HttpContext.Current.User.Identity.GetUserId();
            var json   = new StreamReader(req).ReadToEnd();
            var data   = JsonConvert.DeserializeObject <VoteData>(json);

            Sighting sighting = db.Sightings.Find(data.Id);

            sighting.Rating          = data.Increase ? sighting.Rating + 1 : sighting.Rating - 1;
            db.Entry(sighting).State = EntityState.Modified;

            var preVote = db.Votes.Where(xx => xx.AspNetUserId == userId && xx.SightingId == data.Id).FirstOrDefault();

            if (preVote != null)
            {
                db.Votes.Remove(preVote);
            }

            Vote vote = new Vote();

            vote.SightingId   = data.Id;
            vote.AspNetUserId = userId;


            if (data.Increase)
            {
                vote.Action = VoteAction.Up;
            }
            else
            {
                vote.Action = VoteAction.Down;
            }

            db.Votes.Add(vote);
            db.SaveChanges();

            var sightingMapped = new SightingDTO();

            sightingMapped.SightingId   = sighting.SightingId;
            sightingMapped.AspNetUserId = sighting.AspNetUserId;
            sightingMapped.Latitude     = sighting.Latitude;
            sightingMapped.Longitude    = sighting.Longitude;
            sightingMapped.PokeMon      = sighting.PokeMon != null?sighting.PokeMon.GetDescription() : null;

            sightingMapped.Rarity     = sighting.Rarity.GetDescription();
            sightingMapped.Rating     = sighting.Rating;
            sightingMapped.SightingId = sighting.SightingId;
            sightingMapped.Type       = sighting.Type.GetDescription();
            sightingMapped.TimeOfDay  = sighting.TimeOfDay.ToString();


            return(Json(sightingMapped, JsonRequestBehavior.AllowGet));
        }
        public ActionResult CreateSighting()
        {
            var req    = Request.InputStream;
            var json   = new StreamReader(req).ReadToEnd();
            var result = JsonConvert.DeserializeObject <Sighting>(json);
            var bounds = JsonConvert.DeserializeObject <Bounds>(json);

            if (!IsSightingDuplicate(result, bounds))
            {
                var userId   = System.Web.HttpContext.Current.User.Identity.GetUserId();
                var sighting = new Sighting();
                sighting.Longitude    = result.Longitude;
                sighting.Latitude     = result.Latitude;
                sighting.AspNetUserId = userId;
                sighting.Type         = result.Type;
                sighting.Rarity       = result.Rarity;
                sighting.PokeMon      = result.PokeMon;
                sighting.TimeOfDay    = result.TimeOfDay;
                sighting.Notes        = result.Notes;

                db.Sightings.Add(sighting);

                db.SaveChanges();

                Vote vote = new Vote();
                vote.SightingId   = sighting.SightingId;
                vote.AspNetUserId = userId;
                vote.Action       = VoteAction.Up;
                db.Votes.Add(vote);

                db.SaveChanges();

                var sightingMapped = new SightingDTO();

                sightingMapped.SightingId   = sighting.SightingId;
                sightingMapped.AspNetUserId = sighting.AspNetUserId;
                sightingMapped.Latitude     = sighting.Latitude;
                sightingMapped.Longitude    = sighting.Longitude;
                sightingMapped.PokeMon      = sighting.PokeMon != null?sighting.PokeMon.GetDescription() : null;

                sightingMapped.Rarity     = sighting.Rarity.GetDescription();
                sightingMapped.Rating     = sighting.Rating;
                sightingMapped.SightingId = sighting.SightingId;
                sightingMapped.Type       = sighting.Type.GetDescription();
                sightingMapped.TimeOfDay  = sighting.TimeOfDay.ToString();
                sightingMapped.Notes      = sighting.Notes;


                return(Json(sightingMapped, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(new HttpStatusCodeResult(409, "This pokemon has already been added to this area"));
            }
        }