Exemple #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            MassageTherapist massageTherapist = db.MassageTherapists.Find(id);

            db.MassageTherapists.Remove(massageTherapist);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #2
0
        // GET: MassageTherapists/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MassageTherapist massageTherapist = db.MassageTherapists.Find(id);

            if (massageTherapist == null)
            {
                return(HttpNotFound());
            }
            return(View(massageTherapist));
        }
Exemple #3
0
        // GET: MassageTherapists/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MassageTherapist massageTherapist = db.MassageTherapists.Find(id);

            if (massageTherapist == null)
            {
                return(HttpNotFound());
            }
            ViewBag.ApplicationId = new SelectList(db.Users, "Id", "Email", massageTherapist.ApplicationId);
            return(View(massageTherapist));
        }
Exemple #4
0
        public async Task <ActionResult> Create(MassageTherapist massageTherapist)
        {
            var session = Convert.ToInt32(massageTherapist.SessionPerDay);

            if (ModelState.IsValid)
            {
                massageTherapist.ApplicationId = userId;
                await GetCoord(massageTherapist);

                db.MassageTherapists.Add(massageTherapist);
                db.SaveChanges();
                return(RedirectToAction("LogOut", "Account"));
            }

            ViewBag.ApplicationId = new SelectList(db.Users, "Id", "Email", massageTherapist.ApplicationId);
            return(View(massageTherapist));
        }
Exemple #5
0
        public async Task <ActionResult> GetCoord(MassageTherapist therapist)
        {
            string              location = therapist.Street + "+" + therapist.City + "+" + therapist.State + "+" + therapist.Zip;
            HttpClient          client   = new HttpClient();
            string              url      = "https://maps.googleapis.com/maps/api/geocode/json?address=" + location + "&key=" + GoogleMapKey.myKey;
            HttpResponseMessage response = await client.GetAsync(url);

            string result = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                GeoModel GeoResult = JsonConvert.DeserializeObject <GeoModel>(result);
                therapist.Latitude  = GeoResult.results[0].geometry.location.lat;
                therapist.Longitude = GeoResult.results[0].geometry.location.lng;

                return(View(therapist));
            }

            return(View(therapist));
        }
Exemple #6
0
 public async Task <ActionResult> Edit(MassageTherapist massageTherapist)
 {
     if (ModelState.IsValid)
     {
         var therapist = db.MassageTherapists.Include(t => t.ApplicationUser).Where(t => t.ApplicationId == userId).SingleOrDefault();
         therapist.FirstName = massageTherapist.FirstName;
         therapist.LastName  = massageTherapist.LastName;
         if (therapist.Street != massageTherapist.Street || therapist.City != massageTherapist.City || therapist.State != massageTherapist.State || therapist.Zip != massageTherapist.Zip)
         {
             await GetCoord(massageTherapist);
         }
         therapist.Street        = massageTherapist.Street;
         therapist.City          = massageTherapist.City;
         therapist.State         = massageTherapist.State;
         therapist.Zip           = massageTherapist.Zip;
         therapist.TimeFramePref = massageTherapist.TimeFramePref;
         therapist.Specialty     = massageTherapist.Specialty;
         therapist.SessionPerDay = massageTherapist.SessionPerDay;
         db.SaveChanges();
         return(RedirectToAction("Details"));
     }
     ViewBag.ApplicationId = new SelectList(db.Users, "Id", "Email", massageTherapist.ApplicationId);
     return(View(massageTherapist));
 }
Exemple #7
0
        // GET: MassageTherapists/Details/5
        public ActionResult Details(int?id, MTAppointViewModel viewModel)
        {
            MassageTherapist therapist = null;

            if (id != null)
            {
                therapist = db.MassageTherapists.Include(t => t.ApplicationUser).Where(t => t.Id == id).SingleOrDefault();
                var client = db.Clients.Where(c => c.ApplicationId == userId).SingleOrDefault();
                ViewBag.ClientLat = client.Latitude;
                ViewBag.ClientLng = client.Longitude;
            }
            else
            {
                therapist = db.MassageTherapists.Include(t => t.ApplicationUser).Where(t => t.ApplicationId == userId).SingleOrDefault();
            }
            if (therapist == null)
            {
                return(HttpNotFound());
            }

            ViewBag.Map = "https://maps.googleapis.com/maps/api/js?key=" + GoogleMapKey.myKey + "&callback=initMap";

            return(View(therapist));
        }