public int DoSaveData(FormCollection form, int?ID = null) { int identityId = 0; TEAM saveModel; using (var db = new RITUAL()) { if (ID == 0) { saveModel = new TEAM(); saveModel.BUD_ID = UserProvider.Instance.User.ID; saveModel.BUD_DT = DateTime.UtcNow.AddHours(8); } else { saveModel = db.TEAM.Where(s => s.ID == ID).FirstOrDefault(); } bool tryStatus = false; bool status = true; if (bool.TryParse(form["fSt"], out tryStatus)) { status = Convert.ToBoolean(form["fSt"]); } saveModel.MAP_AREA_ID = Convert.ToInt32(form["area"]); saveModel.MAP_CITY_ID = Convert.ToInt32(form["city"]); saveModel.COMPANY_NM = form["companyName"]; saveModel.ADDR = form["addr"]; saveModel.CONTACT = form["contact"]; saveModel.PHONE = form["phone"]; saveModel.SQ = Convert.ToInt32(form["sq"]); saveModel.DISABLED = status; saveModel.UP_DT = DateTime.UtcNow.AddHours(8); saveModel.UP_ID = UserProvider.Instance.User.ID; PublicMethodRepository.FilterXss(saveModel); if (ID == 0) { db.TEAM.Add(saveModel); } else { db.Entry(saveModel).State = EntityState.Modified; } try { db.SaveChanges(); } catch (Exception ex) { throw ex; } identityId = (int)saveModel.ID; } return(identityId); }
public ActivityListResultModel DoGetList(ActivityFilterModel filterModel) { PublicMethodRepository.FilterXss(filterModel); ActivityListResultModel result = new ActivityListResultModel(); Dictionary <int, bool> validActivityStatus = new Dictionary <int, bool>(); List <OLACT> data = new List <OLACT>(); try { data = DB.OLACT.ToList(); //關鍵字搜尋 if (!string.IsNullOrEmpty(filterModel.QueryString)) { this.ListFilter(filterModel.QueryString, ref data); } //發佈日期搜尋 if (!string.IsNullOrEmpty(filterModel.PublishDate)) { this.ListDateFilter((filterModel.PublishDate), ref data); } //上下架 if (!string.IsNullOrEmpty(filterModel.Disable)) { this.ListStatusFilter(filterModel.Disable, ref data); } //排序 this.ListSort(filterModel.SortColumn, ref data); PaginationResult pagination; //分頁 this.ListPageList(filterModel.CurrentPage, ref data, out pagination); result.Pagination = pagination; foreach (var d in data) { PublicMethodRepository.HtmlDecode(d); } result.Data = data; foreach (var d in data) { if (!validActivityStatus.ContainsKey(d.ID)) { validActivityStatus.Add(d.ID, true); } validActivityStatus[d.ID] = ActivityStatusCheckByID(d.ID); } result.ValidActivityStatusBuffer = validActivityStatus; } catch (Exception ex) { throw ex; } return(result); }
public NewsListResultModel DoGetList(NewsListFilterModel filterModel) { PublicMethodRepository.FilterXss(filterModel); NewsListResultModel result = new NewsListResultModel(); List <NEWS> data = new List <NEWS>(); try { data = DB.NEWS.ToList(); //關鍵字搜尋 if (!string.IsNullOrEmpty(filterModel.QueryString)) { this.ListFilter(filterModel.QueryString, ref data); } //發佈日期搜尋 if (!string.IsNullOrEmpty(filterModel.PublishDate)) { this.ListDateFilter(filterModel.PublishDate, ref data); } //首頁顯示 if (!string.IsNullOrEmpty(filterModel.DisplayForHomePage)) { this.ListStatusFilter(filterModel.DisplayForHomePage, "DisplayHome", ref data); } //上下架 if (!string.IsNullOrEmpty(filterModel.Disable)) { this.ListStatusFilter(filterModel.Disable, "Disable", ref data); } //排序 this.ListSort(filterModel.SortColumn, ref data); PaginationResult pagination; //分頁 this.ListPageList(filterModel.CurrentPage, ref data, out pagination); result.Pagination = pagination; foreach (var d in data) { PublicMethodRepository.HtmlDecode(d); } result.Data = data; } catch (Exception ex) { throw ex; } return(result); }
public string SaveProductInfo(FormCollection form) { bool status = form["Status"] == "Y" ? true : false; string content = form["contenttext"]; PublicMethodRepository.FilterXss(content); using (var db = new REDOXDB()) { ModelInitProperty saveModel = ModelInitProperty.NotSet; LISTEDITOR entity = db.LISTEDITOR.Where(s => s.OBJ_NAME == _actionName).FirstOrDefault(); if (entity == null) { entity = new LISTEDITOR { OBJ_NAME = _actionName, BUD_DT = DateTime.UtcNow.AddHours(8), BUD_ID = UserProvider.Instance.User.ID }; saveModel = ModelInitProperty.New; } else { saveModel = ModelInitProperty.FromDB; } entity.STATUS = status; entity.OBJ_CONTENT = content; entity.UP_DT = DateTime.UtcNow.AddHours(8); entity.UP_ID = UserProvider.Instance.User.ID; if (saveModel == ModelInitProperty.New) { db.LISTEDITOR.Add(entity); } else { db.Entry(entity).State = System.Data.Entity.EntityState.Modified; } try { db.SaveChanges(); } catch (Exception ex) { throw ex; } } return(_actionName); }
public int DoSaveData(FormCollection form, int?ID = null) { NEWS saveModel; if (ID == 0) { saveModel = new NEWS(); saveModel.BUD_ID = UserProvider.Instance.User.ID; saveModel.BUD_DT = DateTime.UtcNow.AddHours(8); } else { saveModel = this.DB.NEWS.Where(s => s.ID == ID).FirstOrDefault(); } saveModel.TITLE = form["title"]; saveModel.HOME_PAGE_DISPLAY = form["disHome"] == "on" ? true : false; saveModel.DISABLE = form["disable"] == null ? false : Convert.ToBoolean(form["disable"]); saveModel.SQ = form["sortIndex"] == null ? 1 : Convert.ToDouble(form["sortIndex"]); saveModel.CONTENT = form["contenttext"]; saveModel.PUB_DT_STR = form["publishDate"]; saveModel.UPT_DT = DateTime.UtcNow.AddHours(8); saveModel.UPT_ID = UserProvider.Instance.User.ID; PublicMethodRepository.FilterXss(saveModel); if (ID == 0) { this.DB.NEWS.Add(saveModel); } else { this.DB.Entry(saveModel).State = EntityState.Modified; } try { this.DB.SaveChanges(); } catch (Exception ex) { throw ex; } int identityId = (int)saveModel.ID; return(identityId); }
public BannerListResultModel DoGetList(BannerFilterModel filterModel) { PublicMethodRepository.FilterXss(filterModel); BannerListResultModel result = new BannerListResultModel(); List <BANNER> data = new List <BANNER>(); try { data = DB.BANNER.ToList(); //關鍵字搜尋 if (!string.IsNullOrEmpty(filterModel.QueryString)) { this.ListFilter(filterModel.QueryString, ref data); } //上下架 if (!string.IsNullOrEmpty(filterModel.Disable)) { this.ListStatusFilter(filterModel.Disable, ref data); } //排序 this.ListSort(filterModel.SortColumn, ref data); PaginationResult pagination; //分頁 this.ListPageList(filterModel.CurrentPage, ref data, out pagination); result.Pagination = pagination; foreach (var d in data) { PublicMethodRepository.HtmlDecode(d); } result.Data = data; } catch (Exception ex) { throw ex; } return(result); }
public SearchListResultModel SearchSite(SearchListFilterModel filter) { PublicMethodRepository.FilterXss(filter); string str = filter.QueryString; SearchListResultModel result = new SearchListResultModel(); List <SearchListDataModel> data = new List <SearchListDataModel>(); SearchAbout(filter.QueryString, filter.LangCode, ref data); SearchEducation(filter.QueryString, filter.LangCode, ref data); SearchJoinUs(filter.QueryString, filter.LangCode, ref data); SearchEventLatest(filter.QueryString, filter.LangCode, ref data); SearchStates(filter.QueryString, filter.LangCode, ref data); SearchAnnouncement(filter.QueryString, filter.LangCode, ref data); SearchFocus(filter.QueryString, filter.LangCode, ref data); //result.Data = data.OrderByDescending(o => o.UpDateTime).ToList(); result.Data = data.OrderByDescending(o => o.Sort).ThenByDescending(x => x.BD_DTString).ToList(); result = ListPagination(result, (int)filter.CurrentPage, (int)PageSizeConfig.SIZE10); return(result); }
public void SaveContent(string content) { FileRepository fileRepository = new FileRepository(); EDITOR agent = null; var @base = DB.EDITOR.FirstOrDefault(); if (@base == null) { agent = new EDITOR() { CONTENT = content } } ; else { @base.CONTENT = content; agent = @base; } PublicMethodRepository.FilterXss(agent); if (@base == null) { this.DB.EDITOR.Add(agent); } else { this.DB.Entry(agent).State = EntityState.Modified; } try { this.DB.SaveChanges(); } catch (Exception ex) { throw ex; } }
public bool ChangePassword(FormCollection form) { if (UserProvider.Instance.User == null) { throw new Exception("請先登入!"); } var oldPwd = form["oldPw"]; var newPwd = form["newPw"]; var rePwd = form["rePw"]; var entityUser = this.DB.USER .Where(o => o.ID == UserProvider.Instance.User.ID && o.USR_ID == UserProvider.Instance.User.UserAccount).First(); PublicMethodRepository.HtmlDecode(entityUser); bool isTruePw = (oldPwd == entityUser.USR_PWD); if (isTruePw) { if (newPwd.Equals(rePwd)) { PublicMethodRepository.FilterXss(entityUser); entityUser.USR_PWD = rePwd; this.DB.Entry(entityUser).State = EntityState.Modified; this.DB.SaveChanges(); } else { throw new Exception("新密碼兩次輸入密碼不同."); } } else { throw new Exception("原密碼輸入錯誤."); } return(true); }
public int DoSaveData(DownloadDataModel model) { DLFILES saveModel; FileRepository fileRepository = new FileRepository(); if (model.ID == 0) { saveModel = new DLFILES(); saveModel.BUD_ID = UserProvider.Instance.User.ID; saveModel.BUD_DT = DateTime.UtcNow.AddHours(8); } else { saveModel = this.DB.DLFILES.Where(s => s.ID == model.ID).FirstOrDefault(); } saveModel.TITLE = model.Title; saveModel.SQ = model.Sort; saveModel.PUB_DT_STR = model.PublishDateStr; saveModel.DISABLE = model.Disable; saveModel.UPT_ID = UserProvider.Instance.User.ID; saveModel.UPT_DT = DateTime.UtcNow.AddHours(8); PublicMethodRepository.FilterXss(saveModel); if (model.ID == 0) { this.DB.DLFILES.Add(saveModel); } else { this.DB.Entry(saveModel).State = EntityState.Modified; } try { this.DB.SaveChanges(); } catch (Exception ex) { throw ex; } int identityId = (int)saveModel.ID; #region 檔案處理 FilesModel fileModel = new FilesModel() { ActionName = "Download", ID = identityId, OldFileIds = model.OldFilesId }; fileRepository.UploadFile("Post", fileModel, model.Files, "M"); fileRepository.SaveFileToDB(fileModel); #endregion 檔案處理 return(identityId); }
public override object DoGetList(object filter) { ListResultBase result = new ListResultBase(); TFilter filterModel = (filter as TFilter); PublicMethodRepository.FilterXss(filterModel); List <TData> data = new List <TData>(); try { var enumerable = (IEnumerable <TData>)(typeof(REDOXDB).GetProperty(typeof(TData).Name).GetValue(DB, null)); if (PublicMethodRepository.CurrentMode == SiteMode.FronEnd) { data = enumerable.Where(s => !s.DISABLE).ToList(); } else if (PublicMethodRepository.CurrentMode == SiteMode.Home) { data = enumerable.Where(s => !s.DISABLE && s.HOME_PAGE_DISPLAY).ToList(); } else { data = enumerable.ToList(); } //關鍵字搜尋 if (!string.IsNullOrEmpty(filterModel.QueryString)) { data = this.DoListFilterStringQuery(filterModel.QueryString, data); } //PUB_DT_STR搜尋 if (!string.IsNullOrEmpty(filterModel.PublishStartDate) && !string.IsNullOrEmpty(filterModel.PublishEndate)) { data = this.DoListDateFilter(Convert.ToDateTime(filterModel.PublishStartDate), Convert.ToDateTime(filterModel.PublishEndate), data); } //前台顯示 if (!string.IsNullOrEmpty(filterModel.DisplayForFrontEnd)) { data = this.DoListStatusFilter(filterModel.DisplayForFrontEnd, "F", data); } //SQ data = this.DoListSort(filterModel.SortColumn, filterModel.Status, data); //分頁 //分頁 bool isDoPage = PublicMethodRepository.CurrentMode == SiteMode.FronEnd || PublicMethodRepository.CurrentMode == SiteMode.Home ? false : true; data = this.DoListPageList(filterModel.CurrentPage, data, out PaginationResult pagination, isDoPage); result.Pagination = pagination; foreach (var d in data) { PublicMethodRepository.HtmlDecode(d); } result.Data = data; } catch (Exception ex) { throw ex; } return(result); }
public override int DoSaveData(FormCollection form, int?ID = null, List <HttpPostedFileBase> files = null) { NEWS saveModel; FileRepository fileRepository = new FileRepository(); if (!ID.HasValue) { saveModel = new NEWS(); saveModel.BUD_DT = DateTime.UtcNow.AddHours(8); saveModel.BUD_ID = UserProvider.Instance.User.ID; } else { saveModel = this.DB.NEWS.Where(s => s.ID == ID).FirstOrDefault(); } saveModel.TITLE = form["TITLE"]; saveModel.HOME_PAGE_DISPLAY = form["HOME_PAGE_DISPLAY"] == "on" ? true : false; saveModel.DISABLE = form["DISABLE"] == "Y" ? true : false; saveModel.SQ = form["SQ"] == null ? 1 : form["SQ"] == string.Empty ? 1 : Convert.ToInt32(form["SQ"]); saveModel.CONTENT = form["contenttext"]; saveModel.PUB_DT_STR = form["PUB_DT_STR"]; saveModel.UPT_DT = DateTime.UtcNow.AddHours(8); saveModel.UPT_ID = UserProvider.Instance.User.ID; PublicMethodRepository.FilterXss(saveModel); if (ID.HasValue) { this.DB.Entry(saveModel).State = EntityState.Modified; } else { this.DB.NEWS.Add(saveModel); } try { this.DB.SaveChanges(); } catch (Exception ex) { ex.AppException(); } int identityId = (int)saveModel.ID; #region FILEBASE處理 List <int> oldFileList = new List <int>(); #region 將原存在的ServerFILEBASE保留 記錄FILEBASEID //將原存在的ServerFILEBASE保留 記錄FILEBASEID foreach (var f in form.Keys) { if (f.ToString().StartsWith("FileData")) { var id = Convert.ToInt16(form[f.ToString().Split('.')[0] + ".ID"]); if (!oldFileList.Contains(id)) { oldFileList.Add(id); } } } #endregion 將原存在的ServerFILEBASE保留 記錄FILEBASEID #region 建立FILEBASE模型 FilesModel fileModel = new FilesModel() { ActionName = _actionName, ID = identityId, OldFileIds = oldFileList }; #endregion 建立FILEBASE模型 #region 若有null則是前端html的name重複於ajax formData名稱 if (files != null) { if (files.Count > 0) { files.RemoveAll(item => item == null); } } #endregion 若有null則是前端html的name重複於ajax formData名稱 #region img data binding 單筆多筆裝在不同容器 fileRepository.UploadFile(fileModel, files, identityId, _actionName); fileRepository.SaveFileToDB(fileModel); #endregion img data binding 單筆多筆裝在不同容器 #endregion FILEBASE處理 return(identityId); }
public int DoSaveData(ActivityDataModel model) { OLACT saveModel; FileRepository fileRepository = new FileRepository(); if (!model.ID.HasValue) { saveModel = new OLACT(); saveModel.BUD_ID = UserProvider.Instance.User.ID; saveModel.BUD_DT = DateTime.UtcNow.AddHours(8); } else { saveModel = this.DB.OLACT.Where(s => s.ID == model.ID).FirstOrDefault(); } saveModel.ACTITLE = model.Title; saveModel.SQ = model.Sort; saveModel.PUB_DT_STR = model.PublishDateStr; saveModel.APPLY_DATE_BEGIN = model.ApplyDateTimeBegin; saveModel.APPLY_DATE_END = model.ApplyDateTimeEnd; saveModel.ACT_CONTENT = model.contenttext; saveModel.ACT_NUM = model.ActivityNumber; saveModel.ACT_DATE_DESC = model.ActivityDateTimeDescription; saveModel.DISABLE = model.Disable; saveModel.UPD_ID = UserProvider.Instance.User.ID; saveModel.UPD_DT = DateTime.UtcNow.AddHours(8); PublicMethodRepository.FilterXss(saveModel); if (!model.ID.HasValue) { this.DB.OLACT.Add(saveModel); } else { this.DB.Entry(saveModel).State = EntityState.Modified; } try { this.DB.SaveChanges(); } catch (Exception ex) { throw ex; } int identityId = (int)saveModel.ID; #region 組別 List <OLACTGROUP> groupUpdateEntity = new List <OLACTGROUP>(); List <OLACTGROUP> groupAddEntity = new List <OLACTGROUP>(); List <int> oldIds = model.ActivityGroup.Where(o => o.GroupID > 0).Select(s => s.GroupID).ToList(); using (var transation = DB.Database.CurrentTransaction ?? DB.Database.BeginTransaction()) { var removeNotInEntities = DB.OLACTGROUP.Where(o => o.MAP_ACT_ID == identityId && !oldIds.Contains(o.ID)); if (removeNotInEntities.Count() > 0) { DB.OLACTGROUP.RemoveRange(removeNotInEntities); } foreach (var group in model.ActivityGroup) { OLACTGROUP temp = null; if (group.GroupID == 0) { temp = new OLACTGROUP(); temp.BUD_DT = DateTime.UtcNow.AddHours(8); temp.BUD_ID = UserProvider.Instance.User.ID; } else { temp = DB.OLACTGROUP.Where(o => o.ID == group.GroupID).First(); } temp.MAP_ACT_ID = identityId; temp.GROUP_NAME = group.GroupName; temp.TEAM_APPLY_LIMIT = group.GroupApplyLimit; temp.COUNT_APPLY_LIMIT = group.CountApplyLimit; temp.UPD_DT = DateTime.UtcNow.AddHours(8); temp.UPD_ID = UserProvider.Instance.User.ID; if (group.GroupID == 0) { groupAddEntity.Add(temp); } else { groupUpdateEntity.Add(temp); } } foreach (var item in groupUpdateEntity) { this.DB.Entry(item).State = EntityState.Modified; } if (groupAddEntity.Count > 0) { this.DB.OLACTGROUP.AddRange(groupAddEntity); } try { DB.SaveChanges(); transation.Commit(); } catch (Exception ex) { transation.Rollback(); throw ex; } } #endregion #region 檔案處理 FilesModel fileModel = new FilesModel() { ActionName = "Activity", ID = identityId, OldFileIds = model.OldFilesId }; fileRepository.UploadFile("Post", fileModel, model.Files, "M"); fileRepository.SaveFileToDB(fileModel); #endregion 檔案處理 return(identityId); }
public TeamListResultModel DoGetList(TeamListFilterModel filterModel) { PublicMethodRepository.FilterXss(filterModel); TeamListResultModel result = new TeamListResultModel(); List <TEAM> data = new List <TEAM>(); using (var db = new RITUAL()) { try { data = db.TEAM.ToList(); //關鍵字搜尋 if (!string.IsNullOrEmpty(filterModel.QueryString)) { this.ListFilter(filterModel.QueryString, ref data); } if (filterModel.CityID.HasValue) { this.ListFilterCity(filterModel.CityID.Value, ref data); } if (filterModel.AreaID.HasValue) { this.ListFilterArea(filterModel.AreaID.Value, ref data); } //發佈日期搜尋 //if (!string.IsNullOrEmpty(filterModel.PublishDate)) //{ // this.ListDateFilter(filterModel.PublishDate, ref data); //} //前台顯示 //if (!string.IsNullOrEmpty(filterModel.Disable)) //{ // this.ListStatusFilter(filterModel.Disable, "Display", ref data); //} //上下架 //if (!string.IsNullOrEmpty(filterModel.Disable)) //{ // this.ListStatusFilter(filterModel.Disable, "Disable", ref data); //} //排序 this.ListSort(filterModel.SortColumn, ref data); PaginationResult pagination; //分頁 this.ListPageList(filterModel.CurrentPage, ref data, out pagination, filterModel.DoPagination); result.Pagination = pagination; foreach (var d in data) { PublicMethodRepository.HtmlDecode(d); } result.Data = data; } catch (Exception ex) { throw ex; } } return(result); }