public ActionResult ActivitiesMain(DataAction ActionType, string guid, string selectCreateTime, string selectTitleName, string selectHtmlContext, string selectStartDate, string selectEndDate, int pages = 1) { TempData["DataAction"] = ActionType; ActitiesDetailViewModel data = new ActitiesDetailViewModel(); data = _ActivityService.ReturnActitiesDetailViewModel(ActionType, guid); #region KeepSelectBlock pages = pages == 0 ? 1 : pages; TempData["ActitiesSelect"] = new ActitiesViewModel() { Header = new ActitiesListHeaderViewModel() { CreateTime = selectCreateTime, EndDate = selectEndDate, HtmlContext = selectHtmlContext, StartDate = selectStartDate, TitleName = selectTitleName }, page = pages }; #endregion KeepSelectBlock return(View(data)); }
/// <summary> /// ViewModel To DBModel /// </summary> /// <param name="viewModel"></param> /// <returns></returns> private Activity ReturnMappingActity(ActitiesDetailViewModel viewModel) { Activity dbViewModel = new Activity(); var mapper = AutoMapperConfig.InitializeAutoMapper().CreateMapper(); dbViewModel = mapper.Map <Activity>(viewModel); return(dbViewModel); }
public ActitiesDetailViewModel ReturnActitiesDetailViewModel(DataAction ActionType, string guid) { ActitiesDetailViewModel DetailViewModel = new ActitiesDetailViewModel(); ActitiesDBViewModel StaticHtmlDBViewModel = _ActityRep.GetSingle(guid); if (StaticHtmlDBViewModel == null) { StaticHtmlDBViewModel = new ActitiesDBViewModel(); } var mapper = AutoMapperConfig.InitializeAutoMapper().CreateMapper(); DetailViewModel = mapper.Map <ActitiesDetailViewModel>(StaticHtmlDBViewModel); return(DetailViewModel); }
/// <summary> /// Update StaticHtml /// </summary> /// <param name="statichtml"></param> /// <returns></returns> public string Update(ActitiesDetailViewModel statichtml, string userName) { try { //Activity PartStaticHtml = ReturnMappingActity(statichtml); //PartStaticHtml.SubjectID = statichtml.StaticHtmlActionType.ToString(); //_StaticHtmlRep.StaticHtmlUpdate(PartStaticHtml, userName); return(EnumHelper.GetEnumDescription(DataAction.UpdateScuess)); } catch { return(EnumHelper.GetEnumDescription(DataAction.UpdateFail)); } }
/// <summary> /// Create StaticHtml Info /// </summary> /// <param name="statichtml"></param> public string Create(ActitiesDetailViewModel actity, string userName) { try { Activity PartStaticHtml = ReturnMappingActity(actity); _ActityRep.ActitiesInsertInto(PartStaticHtml, userName); return(EnumHelper.GetEnumDescription(DataAction.CreateScuess)); } catch { return(EnumHelper.GetEnumDescription(DataAction.CreateFail)); } }
//[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)); }