public ActionResult DetailProvider(int id) { AroundProvider curProvider = _aroundProviderService.FindById(id); AroundProviderDetailModel providerDetail = new AroundProviderDetailModel(); providerDetail.Id = curProvider.Id; providerDetail.Name = curProvider.Name; providerDetail.Address = curProvider.Address; providerDetail.Description = curProvider.Description; providerDetail.ImageUrl = curProvider.ImageUrl; providerDetail.Tel = curProvider.Tel; //providerDetail.ClickCount = curProvider.ClickCount; return(Json(providerDetail)); //ViewBag.providerDetail = providerDetail; //return View("View"); }
public ActionResult ViewGetAllAroundProvider(int?catId) { List <AroundProvider> providers = _aroundProviderService.GetAllProviderWithCat(null); if (catId != null) { AroundProviderCategory curentCat = _aroundProviderCategoryService.FindById(catId.Value); if (null == curentCat) { ViewBag.ErrorMsg = " Rất tiếc không tìm thấy loại dịch vụ xung quanh"; return(View("~/Views/Post/ErrorMsg.cshtml")); } } List <AroundProviderCategory> allCat = _aroundProviderCategoryService.GetAllOrderByProviderClickCount(); AroundProviderDetailModel providerDetail = null; List <AroundProviderDetailModel> providerDetailList = new List <AroundProviderDetailModel>(); foreach (var provider in providers) { providerDetail = new AroundProviderDetailModel(); providerDetail.Id = provider.Id; providerDetail.Name = provider.Name; providerDetail.ProviderCatId = provider.AroundProviderCategoryId.Value; providerDetail.Address = provider.Address; providerDetail.ClickCount = provider.ClickCount.Value; providerDetail.ImageUrl = provider.ImageUrl; providerDetail.RatePoint = provider.UserRateAroundProviders.ToList().Count == 0 ? 0.0 : provider.UserRateAroundProviders.Average(r => r.Point).Value; providerDetailList.Add(providerDetail); } ViewBag.AllCategorys = allCat; if (allCat.Count != 0 && catId == null) { ViewBag.highestProCat = allCat.First().Id; } else if (catId != null) { ViewBag.highestProCat = catId; } ViewBag.AllProviders = providerDetailList; return(View("ViewAroundProviderDetail")); }
public ActionResult UpdateProvider(AroundProviderDetailModel aroundProviderDetailModel) { AroundProvider curProvider = _aroundProviderService.FindById(aroundProviderDetailModel.Id); curProvider.Name = aroundProviderDetailModel.Name; curProvider.Description = aroundProviderDetailModel.Description; curProvider.Address = aroundProviderDetailModel.Address; curProvider.Tel = aroundProviderDetailModel.Tel; _aroundProviderService.Update(curProvider); //try //{ // _aroundProviderService.Update(curProvider); //} //catch (Exception) //{ // string message = "Cannot update!"; // return Json(message); //} return(RedirectToAction("ManageAroundProvider")); //return RedirectToAction("ManageAroundProvider"); }
public ActionResult CreateAroundProvider(AroundProviderDetailModel aroundProviderDetailModel) { MessageViewModels response = new MessageViewModels(); try { AroundProvider provider = new AroundProvider(); provider.Name = aroundProviderDetailModel.Name; provider.Description = aroundProviderDetailModel.Description; provider.Address = aroundProviderDetailModel.Address; provider.Tel = aroundProviderDetailModel.Tel; provider.ImageUrl = aroundProviderDetailModel.ImageUrl; _aroundProviderService.Add(provider); } catch (Exception) { response.StatusCode = -1; response.Msg = "Thêm mới thất bại"; } return(Json(response)); }