//[ValidateFile] //上傳照片 日後將此功能抽出 ,日後改使用 MVC File upload unobtrusive validation public ActionResult ActivitiesMain(DataAction actions, ActitiesDetailViewModel ActitiesViewModel, IEnumerable <HttpPostedFileBase> upload) { #region KeepSelectBlock TempData["DataAction"] = actions; TempData["ActitiesSelect"] = (ActitiesViewModel)TempData["ActitiesSelect"]; #endregion KeepSelectBlock if (ModelState.IsValid) { if (actions == DataAction.Create) //建立資料 { ActitiesViewModel.ActivityID = Guid.NewGuid().ToString().ToUpper(); ActitiesViewModel.PicGroupID = Guid.NewGuid().ToString().ToUpper(); //TempData["message"] = _ActivityService.Create(ActitiesViewModel, SignInManagerName); } else //更新資料 { //TempData["message"] = _ActivityService.Update(ActitiesViewModel, SignInManagerName); } #region 傳照片 日後將此功能抽出 if (upload.Where(s => s != null).Count() > 0) { bool UploadResult = UploadFile(upload, ActitiesViewModel.PicGroupID.ToString()); if (UploadResult) { //存入DB _ActivityService.CreatePictureInfo(upload, Guid.Parse(ActitiesViewModel.PicGroupID), SignInManagerName); } } #endregion 傳照片 日後將此功能抽出 _ActivityService.Save(); } // 顯示資料 ActitiesViewModel = _ActivityService.ReturnActitiesDetailViewModel(actions, ActitiesViewModel.ActivityID); return(View(ActitiesViewModel)); }