public ActionResult Info() { var restaurant = memberService.GetRestaurant(Request.Cookies["idCookie"].Values["r_id"]); var infoVM = new RestaurantInfoViewModel(); Mapper.Map(restaurant, infoVM); return(View(infoVM)); }
public ActionResult InfoPartial() { var account = memberService.GetRestaurant(Request.Cookies["idCookie"].Values["r_id"]); account.R_Password = null; var infoVM = new RestaurantInfoViewModel(); Mapper.Map(account, infoVM); return(PartialView("_InfoPartial", infoVM)); }
/// <summary> /// 儲存修改後之餐廳一般資料 /// </summary> /// <param name="_infoVM"></param> /// <returns></returns> public ActionResult SaveInfo(RestaurantInfoViewModel _infoVM) { if (!ModelState.IsValid) { return(View("Info", _infoVM)); } var R_Id = Request.Cookies["idCookie"].Values["r_id"]; if (!Directory.Exists(Server.MapPath($"~/Upload/{R_Id})"))) { DirectoryInfo di = Directory.CreateDirectory(Server.MapPath($"~/Upload/{R_Id}")); } var instance = memberService.GetRestaurant(R_Id); //if has new image to upload 2017/11/8 ChrisWang if (_infoVM.ImageFile != null) { string fileName = Path.GetFileNameWithoutExtension(_infoVM.ImageFile.FileName); string extension = Path.GetExtension(_infoVM.ImageFile.FileName); fileName = fileName + extension; _infoVM.ImagePath = string.Format($"/Upload/{R_Id}/{fileName}"); fileName = Path.Combine(Server.MapPath($"/Upload/{R_Id}/"), fileName); _infoVM.ImageFile.SaveAs(fileName); } Mapper.Map(_infoVM, instance); var result = memberService.Update(instance); if (result.Success) { TempData["Messageinfo"] = "bootbox.alert('修改完成');"; TempData["infoClassColor"] = "green"; } else { TempData["Messageinfo"] = "bootbox.alert('Error!請重新確認後再試一次');"; TempData["infoClassColor"] = "red"; } return(RedirectToAction("Info")); }
public RestaurantInfoPage() { this.InitializeComponent(); viewModel = new RestaurantInfoViewModel(null); }