コード例 #1
0
        /// <summary>
        /// ViewModel To DBModel
        /// </summary>
        /// <param name="viewModel"></param>
        /// <returns></returns>
        private StaticHtml ReturnMappingStaticHtml(StaticHtmlDetailViewModel viewModel)
        {
            StaticHtml dbViewModel = new StaticHtml();
            var        mapper      = AutoMapperConfig.InitializeAutoMapper().CreateMapper();

            dbViewModel = mapper.Map <StaticHtml>(viewModel);
            return(dbViewModel);
        }
コード例 #2
0
        public ActionResult StaticHtmlMain(DataAction ActionType, string guid, string select_CreateTime, string select_HtmlContext, string select_sort,
                                           string selectType, int pages = 1)
        {
            TempData["DataAction"] = ActionType;
            StaticHtmlAction          select = (StaticHtmlAction)Enum.Parse(typeof(StaticHtmlAction), selectType);
            StaticHtmlDetailViewModel data   = new StaticHtmlDetailViewModel();

            data = _StaticHtmlService.ReturnStaticHtmlDetail(select, ActionType, guid);
            PackageTempData(select_CreateTime, select_HtmlContext, select_sort, select, pages);

            return(View(data));
        }
コード例 #3
0
 /// <summary>
 /// Update StaticHtml
 /// </summary>
 /// <param name="statichtml"></param>
 /// <returns></returns>
 public string UpdateStaticHtml(StaticHtmlDetailViewModel statichtml, string userName)
 {
     try
     {
         StaticHtml PartStaticHtml = ReturnMappingStaticHtml(statichtml);
         PartStaticHtml.SubjectID = statichtml.StaticHtmlActionType.ToString();
         _StaticHtmlRep.StaticHtmlUpdate(PartStaticHtml, userName);
         return(EnumHelper.GetEnumDescription(DataAction.UpdateScuess));
     }
     catch
     {
         return(EnumHelper.GetEnumDescription(DataAction.UpdateFail));
     }
 }
コード例 #4
0
        /// <summary>
        /// Returns the static HTML detail.
        /// </summary>
        /// <param name="selectType">Type of the select.</param>
        /// <param name="ActionType">Type of the action.</param>
        /// <param name="guid">The unique identifier.</param>
        /// <returns></returns>
        public StaticHtmlDetailViewModel ReturnStaticHtmlDetail(StaticHtmlAction selectType, DataAction ActionType, string guid)
        {
            StaticHtmlDetailViewModel DetailViewModel       = new StaticHtmlDetailViewModel();
            StaticHtmlDBViewModel     StaticHtmlDBViewModel = _StaticHtmlRep.GetSingle(selectType, guid);

            if (StaticHtmlDBViewModel == null)
            {
                StaticHtmlDBViewModel = new StaticHtmlDBViewModel();
            }
            var mapper = AutoMapperConfig.InitializeAutoMapper().CreateMapper();

            DetailViewModel = mapper.Map <StaticHtmlDetailViewModel>(StaticHtmlDBViewModel);

            /*Enum手動綁進*/
            DetailViewModel.StaticHtmlActionType = selectType;
            return(DetailViewModel);
        }
コード例 #5
0
        //[ValidateFile] //上傳照片 日後將此功能抽出 ,日後改使用 MVC File upload unobtrusive validation
        public ActionResult StaticHtmlMain(DataAction actions, StaticHtmlDetailViewModel satichtmlViewModel,
                                           IEnumerable <HttpPostedFileBase> upload)
        {
            #region KeepSelectBlock

            TempData["DataAction"]       = actions;
            TempData["StaticHtmlSelect"] = (StaticHtmlViewModel)TempData["StaticHtmlSelect"];

            #endregion KeepSelectBlock

            if (ModelState.IsValid)
            {
                if (actions == DataAction.Create) //建立資料
                {
                    satichtmlViewModel.StaticID   = Guid.NewGuid().ToString().ToUpper();
                    satichtmlViewModel.PicGroupID = Guid.NewGuid().ToString().ToUpper();
                    TempData["message"]           = _StaticHtmlService.CreateStaticHtml(satichtmlViewModel, SignInManagerName);
                }
                else //更新資料
                {
                    TempData["message"] = _StaticHtmlService.UpdateStaticHtml(satichtmlViewModel, SignInManagerName);
                }

                #region  傳照片 日後將此功能抽出

                if (upload.Where(s => s != null).Count() > 0)
                {
                    bool UploadResult = UploadFile(upload, satichtmlViewModel.PicGroupID.ToString());
                    if (UploadResult)
                    {
                        //存入DB
                        _StaticHtmlService.CreatePictureInfo(upload, Guid.Parse(satichtmlViewModel.PicGroupID), SignInManagerName);
                    }
                }

                #endregion  傳照片 日後將此功能抽出

                _StaticHtmlService.Save();
            }

            // 顯示資料
            satichtmlViewModel = _StaticHtmlService.ReturnStaticHtmlDetail(satichtmlViewModel.StaticHtmlActionType, actions, satichtmlViewModel.StaticID);
            return(View(satichtmlViewModel));
        }