public JsonResult Register(string phone, string pwd, string name, string city)
        {
            try
            {
                if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(pwd) || string.IsNullOrEmpty(name) || string.IsNullOrEmpty(city))
                    return Json(new { Error = "Invalid input", status = 405 }, JsonRequestBehavior.AllowGet);

                var foodProvider = new FoodProviderModel()
                {
                    Id = phone,
                    City = city.ToLower(),
                    Longititde = 77.391F,
                    Latitude = 28.5355F,
                    Name = name,
                    Password = pwd
                };

                IHomeFoodRepository repo = new HomeFoodRepository();
                repo.RegisterFoodProvider(foodProvider);

                return Json(new { status = 200 }, JsonRequestBehavior.AllowGet);
            }

            catch (Exception ex)
            {
                return Json(new { Error = ex.Message, status = 400 }, JsonRequestBehavior.AllowGet);
            }
        }
        public ActionResult Dashboard(string phone, string pwd)
        {
            try
            {
                if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(pwd))
                    return Json(new { Error = "Invalid input", status = 405 }, JsonRequestBehavior.AllowGet);

                IHomeFoodRepository repo = new HomeFoodRepository();
                var userDetail = repo.GetUser(phone, pwd);

                if (userDetail == null)
                    return Json(new { Message = "Invalid password or phone number", status = 405 }, JsonRequestBehavior.AllowGet);
                else
                {
                    Session["user"] = userDetail;
                    return View("Dashboard", userDetail);
                }

            }

            catch (Exception ex)
            {
                return Json(new { Error = ex.Message, status = 400 }, JsonRequestBehavior.AllowGet);
            }
        }
Exemple #3
0
        public JsonResult AddFoodItem(HttpPostedFileBase file, string providerPhone, string price, string name, string description)
        {
            try
            {
                if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(price))
                    return Json(new { Error = "Invalid input", status = 405 }, JsonRequestBehavior.AllowGet);

                int foodPrice;
                if (!int.TryParse(price, out foodPrice))
                    return Json(new { Error = "Invalid price", status = 405 }, JsonRequestBehavior.AllowGet);

                var foodProvider = (FoodProviderModel)Session["user"];

                var menuModel = new FoodModel()
                {
                    ProviderPhone = foodProvider.Id,
                    Price = foodPrice,
                    Description = description,
                    Image = AddImage(file),
                    Name = name
                };

                IHomeFoodRepository repo = new HomeFoodRepository();
                repo.AddFoodItem(menuModel);

                return Json(new { Message = "Food item added successfully", status = 200 }, JsonRequestBehavior.AllowGet);

            }

            catch (Exception ex)
            {
                return Json(new { Error = ex.Message, status = 400 }, JsonRequestBehavior.AllowGet);
            }
        }
Exemple #4
0
 public JsonResult GetVirtualHotels()
 {
     try
     {
         IHomeFoodRepository repo = new HomeFoodRepository();
         return Json(new { Data = repo.GetVirtualHotels("chandigarh"), status = 200 }, JsonRequestBehavior.AllowGet);
     }
     catch (Exception ex)
     {
         return Json(new { Error = ex.Message, status = 400 }, JsonRequestBehavior.AllowGet);
     }
 }
Exemple #5
0
        public JsonResult AddRating(string providerPhone, string rating)
        {
            try
            {
                if (string.IsNullOrEmpty(providerPhone) || string.IsNullOrEmpty(rating))
                    return Json(new { Error = "Invalid input", status = 405 }, JsonRequestBehavior.AllowGet);

                int providerRating;
                if (!int.TryParse(rating, out providerRating) && providerRating > 0)
                    return Json(new { Error = "Invalid rating", status = 405 }, JsonRequestBehavior.AllowGet);

                IHomeFoodRepository repo = new HomeFoodRepository();
                repo.UpdateRating(providerPhone, providerRating);

                return Json(new { status = 200 }, JsonRequestBehavior.AllowGet);

            }

            catch (Exception ex)
            {
                return Json(new { Error = ex.Message, status = 400 }, JsonRequestBehavior.AllowGet);
            }
        }
Exemple #6
0
        public JsonResult GetHotelDetails(string providerPhone)
        {
            try
            {
                IHomeFoodRepository repo = new HomeFoodRepository();
                var userDetail = repo.GetUser(providerPhone);
                var hotelDetails = repo.GetVirtualHotelDetail(providerPhone);

                var result = new
                {
                    FoodProvider = userDetail,
                    HotelDetails = hotelDetails
                };

                return Json(new { Data = result, status = 200 }, JsonRequestBehavior.AllowGet);

            }

            catch (Exception ex)
            {
                return Json(new { Error = ex.Message, status = 400 }, JsonRequestBehavior.AllowGet);
            }
        }