// GET: Author/Edit/5 public ActionResult Edit(int id) { AuthorsModel _AuthorsModel = AuthorsModel.GetAuthorDetail(id); MenuModel mm = new MenuModel(); List <SelectListItem> AuthorAreaList = new List <SelectListItem>(); var _AuthorAreaList = mm.GetMenu(MenuModel.MenuClassEnum.AuthorArea); for (int i = 0; i < _AuthorAreaList.Count; i++) { AuthorAreaList.Add(new SelectListItem() { Text = _AuthorAreaList[i].MenuName, Value = _AuthorAreaList[i].MenuID.ToString() }); } ViewBag.AuthorAreaList = AuthorAreaList; List <SelectListItem> AuthorTagList = new List <SelectListItem>(); var _AuthorTagList = mm.GetMenu(MenuModel.MenuClassEnum.AuthorTag); for (int i = 0; i < _AuthorTagList.Count; i++) { AuthorTagList.Add(new SelectListItem() { Text = _AuthorTagList[i].MenuName, Value = _AuthorTagList[i].MenuID.ToString() }); } ViewBag.AuthorTagList = AuthorTagList; return(View(_AuthorsModel)); }
public App() { _Name = "ActionAtaDistance1"; try { Version = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(); } catch (InvalidDeploymentException) { //// you cannot read publish version when app isn't installed //// (e.g. during debug) Version = "App not installed."; } authorsModel = new AuthorsModel(); if (ConfigurationManager.AppSettings["EnableLogging"] != null) { if (ConfigurationManager.AppSettings["EnableLogging"].ToLower() == "true") { Logging.CoreEventLog.EnableLogging = true; try { Logging.CoreEventLog.IP_Address = Dns.GetHostAddresses(Environment.MachineName).FirstOrDefault().ToString(); } catch (System.Net.Sockets.SocketException ex) { Logging.CoreEventLog.LogEvent("Dns.GetHostAddresses", null, null, ex.Message, true); } } } }
public ActionResult Index() { var authors = _authorsRepository.GetAll().ToList(); var model = new AuthorsModel() { Authors = authors }; return(View(model)); }
public async Task <AuthorsModel> GetAuthorsAsync() { var authorModel = new AuthorsModel(); var authors = await _authorRepository.GetAllAsync(); foreach (var author in authors) { var model = AuthorMapper.MapEntityToModel(author); authorModel.Items.Add(model); } return(authorModel); }
public MysteryBooksViewModel() { using (var ctx = new AuthorsModel()) { MysteryBooks = ctx.MysteryBooks.Include("Author").Include("MysteryGenre").OrderBy(m => m.BookTitle).ToList(); } //previousID = 0; SaveCommand = new RelayCommand(ExecuteSaveCommand); CancelCommand = new RelayCommand(ExecuteCancelCommand); }
public AuthorsViewModel() { using (var ctx = new AuthorsModel()) { Authors = ctx.Authors.OrderBy(a => a.LastName).ToList(); } previousID = 0; //SaveCommand = new RelayCommand(ExecuteSaveCommand, CanExecuteSaveCommand); SaveCommand = new RelayCommand(ExecuteSaveCommand); CancelCommand = new RelayCommand(ExecuteCancelCommand); }
public JsonResult Delete(string[] id) { for (int i = 0; i < id.Length; i++) { try { // TODO: Add delete logic here AuthorsModel.Delete(Convert.ToInt16(id[i])); } catch { //return View(); return(Json(id[i])); } } return(Json(id)); }
/// <summary> /// This is the default Action. /// </summary> public ActionResult Index() { var model = new AuthorsModel(); if (string.IsNullOrEmpty(this.Title)) { model.Title = "Author"; } else { model.Title = this.Title; } var authors = GetAuthors().Select(i => AuthorViewModel.GetAuthorViewModel(i)); model.Authors = authors.ToList(); return(View("Default", model)); }
public async Task <AuthorsModel> GetAllAsync(AuthorsFilteringModel model) { var authorModel = new AuthorsModel(); var filterModel = FilterMapper.MapAuthorsFilteringModel(model); var authors = await _authorRepository.GetFilteredAsync(filterModel); if (authors == null || !authors.Data.Any()) { authorModel.Errors.Add(ErrorConstants.ImpossibleToFindAuthor); } foreach (var author in authors.Data) { var resultModel = AuthorMapper.MapResponseModelToModelItem(author); authorModel.Items.Add(resultModel); } authorModel.TotalCount = authors.TotalItemsCount; return(authorModel); }
public ActionResult Index(FormCollection collection, int p = 0) { MenuModel.MeunOrderbyTypeEnum _MeunOrderbyTypeEnum = (MenuModel.MeunOrderbyTypeEnum)Enum.Parse(typeof(MenuModel.MeunOrderbyTypeEnum), collection["Sort"], true); List <AuthorsModel> AuthorsModelList = AuthorsModel.GetAuthorList(collection["AuthorsCName"], p + 1, take, _MeunOrderbyTypeEnum); if (AuthorsModelList.Count == (take + 1)) { ViewBag.pn = p + 1; AuthorsModelList.RemoveAt(take); } else { ViewBag.pn = 0; } ViewBag.pi = p; ViewBag.pt = take.ToString(); setSortDropDown(_MeunOrderbyTypeEnum); return(View(AuthorsModelList)); }
// GET: Author public ActionResult Index(int p = 0) { List <AuthorsModel> AuthorsModelList = AuthorsModel.GetAuthorList("", p + 1, take); //多取一,若有表示有下一頁 if (AuthorsModelList.Count == (take + 1)) { ViewBag.pn = p + 1; AuthorsModelList.RemoveAt(take); } else { ViewBag.pn = 0; } ViewBag.pi = p; ViewBag.pt = take.ToString(); setSortDropDown(); return(View(AuthorsModelList)); }
public ActionResult Edit(int id, AuthorsModel AuthorsModel_INPUT) { try { MenuModel mm = new MenuModel(); List <SelectListItem> AuthorAreaList = new List <SelectListItem>(); var _AuthorAreaList = mm.GetMenu(MenuModel.MenuClassEnum.AuthorArea); for (int i = 0; i < _AuthorAreaList.Count; i++) { AuthorAreaList.Add(new SelectListItem() { Text = _AuthorAreaList[i].MenuName, Value = _AuthorAreaList[i].MenuID.ToString() }); } ViewBag.AuthorAreaList = AuthorAreaList; ViewBag.AuthorAreaList = AuthorAreaList; List <SelectListItem> AuthorTagList = new List <SelectListItem>(); var _AuthorTagList = mm.GetMenu(MenuModel.MenuClassEnum.AuthorTag); for (int i = 0; i < _AuthorTagList.Count; i++) { AuthorTagList.Add(new SelectListItem() { Text = _AuthorTagList[i].MenuName, Value = _AuthorTagList[i].MenuID.ToString() }); } ViewBag.AuthorTagList = AuthorTagList; AuthorsModel_INPUT.AuthorsNo = id; // TODO: Add update logic here AuthorsModel_INPUT.Update(); return(RedirectToAction("Index")); } catch { return(View()); } }
private void CreateSelect() { MenuModel mm = new MenuModel(); List <SelectListItem> WorksAuthors = new List <SelectListItem>(); var _WorksAuthors = AuthorsModel.GetAuthorList(); for (int i = 0; i < _WorksAuthors.Count; i++) { WorksAuthors.Add(new SelectListItem() { Text = _WorksAuthors[i].AuthorsCName, Value = _WorksAuthors[i].AuthorsNo.ToString() }); } ViewBag.WorksAuthors = WorksAuthors; List <SelectListItem> WorksModuleList = new List <SelectListItem>(); var _WorksModuleList = mm.GetMenu(MenuModel.MenuClassEnum.Material); for (int i = 0; i < _WorksModuleList.Count; i++) { WorksModuleList.Add(new SelectListItem() { Text = _WorksModuleList[i].MenuName, Value = _WorksModuleList[i].MenuID.ToString() }); } ViewBag.WorksModuleList = WorksModuleList; List <SelectListItem> WorksPropGenreList = new List <SelectListItem>(); var _WorksPropGenreList = mm.GetMenu(MenuModel.MenuClassEnum.Genre); for (int i = 0; i < _WorksPropGenreList.Count; i++) { WorksPropGenreList.Add(new SelectListItem() { Text = _WorksPropGenreList[i].MenuName, Value = _WorksPropGenreList[i].MenuID.ToString() }); } ViewBag.WorksPropGenreList = WorksPropGenreList; List <SelectListItem> WorksPropOwnerList = new List <SelectListItem>(); var _WorksPropOwnerList = mm.GetMenu(MenuModel.MenuClassEnum.Owner); for (int i = 0; i < _WorksPropOwnerList.Count; i++) { WorksPropOwnerList.Add(new SelectListItem() { Text = _WorksPropOwnerList[i].MenuName, Value = _WorksPropOwnerList[i].MenuID.ToString() }); } ViewBag.WorksPropOwnerList = WorksPropOwnerList; List <SelectListItem> WorksPropStyleList = new List <SelectListItem>(); var _WorksPropStyleList = mm.GetMenu(MenuModel.MenuClassEnum.Style); for (int i = 0; i < _WorksPropStyleList.Count; i++) { WorksPropStyleList.Add(new SelectListItem() { Text = _WorksPropStyleList[i].MenuName, Value = _WorksPropStyleList[i].MenuID.ToString() }); } ViewBag.WorksPropStyleList = WorksPropStyleList; List <SelectListItem> WorksPropWareTypeList = new List <SelectListItem>(); var _WorksPropWareTypeList = mm.GetMenu(MenuModel.MenuClassEnum.WareType); for (int i = 0; i < _WorksPropWareTypeList.Count; i++) { WorksPropWareTypeList.Add(new SelectListItem() { Text = _WorksPropWareTypeList[i].MenuName, Value = _WorksPropWareTypeList[i].MenuID.ToString() }); } ViewBag.WorksPropWareTypeList = WorksPropWareTypeList; ViewBag.GradedNoList = new List <SelectListItem>(); List <SelectListItem> WorksCountNounList = new List <SelectListItem>(); var _WorksCountNounList = mm.GetMenu(MenuModel.MenuClassEnum.CountNoun); for (int i = 0; i < _WorksCountNounList.Count; i++) { WorksCountNounList.Add(new SelectListItem() { Text = _WorksCountNounList[i].MenuName, Value = _WorksCountNounList[i].MenuID.ToString() }); } ViewBag.WorksCountNounList = WorksCountNounList; }
// GET: Works public ActionResult Index(int p = 0, string artlist = "", string name = "", string mip = "", string mxp = "", string sort = "") { List <WorksViewModel> model = new List <WorksViewModel>(); ViewBag.OrderbyType = ""; ViewBag.WorksName = ""; ViewBag.AuthorNoList = ""; ViewBag.MinePrice = ""; ViewBag.MaxPrice = ""; WorksSearchModel value = new WorksSearchModel(); value.OrderbyType = MenuModel.WorkOrderbyTypeEnum.作品起始年代大至小; if (!string.IsNullOrEmpty(artlist)) { value.AuthorNoList = artlist.Split(',').ToList(); ViewBag.AuthorNoList = artlist; } if (!string.IsNullOrEmpty(name)) { value.WorksName = name; ViewBag.WorksName = name; } if (!string.IsNullOrEmpty(mip)) { value.MinePrice = Convert.ToInt32(mip); ViewBag.MinePrice = mip; } if (!string.IsNullOrEmpty(mxp)) { value.MaxPrice = Convert.ToInt32(mxp); ViewBag.MaxPrice = mxp; } if (!string.IsNullOrEmpty(sort)) { MenuModel.WorkOrderbyTypeEnum _MeunOrderbyTypeEnum = (MenuModel.WorkOrderbyTypeEnum)Enum.Parse(typeof(MenuModel.WorkOrderbyTypeEnum), sort, true); value.OrderbyType = _MeunOrderbyTypeEnum; ViewBag.OrderbyType = sort; } var _value = value.Search(p + 1, take); //多取一,若有表示有下一頁 if (_value.Count == (take + 1)) { ViewBag.pn = p + 1; _value.RemoveAt(take); } else { ViewBag.pn = 0; } ViewBag.pi = p; for (int i = 0; i < _value.Count; i++) { model.Add(new WorksViewModel() { WorksNo = _value[i].WorksNo, WorksName = _value[i].WorksName, AuthorsName = _value[i].AuthorsName, YearStart = _value[i].YearStart, YearEnd = _value[i].YearEnd, Cost = _value[i].Cost, Price = _value[i].Price, CreateUser = _value[i].CreateUser, Material = _value[i].MaterialsName }); } MenuModel mm = new MenuModel(); List <SelectListItem> WorksAuthors = new List <SelectListItem>(); var _WorksAuthors = AuthorsModel.GetAuthorList(); for (int i = 0; i < _WorksAuthors.Count; i++) { WorksAuthors.Add(new SelectListItem() { Text = _WorksAuthors[i].AuthorsCName, Value = _WorksAuthors[i].AuthorsNo.ToString() }); } ViewBag.WorksAuthors = WorksAuthors; var MeunOrderList = new Dictionary <string, string>(); foreach (var item in Enum.GetValues(typeof(MenuModel.WorkOrderbyTypeEnum))) { MeunOrderList.Add(item.ToString(), item.ToString()); } ViewBag.MeunOrderList = new SelectList(MeunOrderList, "Key", "Value", ViewBag.OrderbyType); ViewBag.pt = take.ToString(); return(View(model)); }
public ActionResult Index(FormCollection collection, int p = 0) { List <WorksViewModel> model = new List <WorksViewModel>(); MenuModel.WorkOrderbyTypeEnum _MeunOrderbyTypeEnum = (MenuModel.WorkOrderbyTypeEnum)Enum.Parse(typeof(MenuModel.WorkOrderbyTypeEnum), collection["Sort"], true); WorksSearchModel value = new WorksSearchModel() { WorksName = collection["WorksName"], OrderbyType = _MeunOrderbyTypeEnum }; ViewBag.OrderbyType = ""; if (!string.IsNullOrEmpty(collection["Sort"])) { ViewBag.OrderbyType = collection["Sort"]; } ViewBag.WorksName = ""; if (!string.IsNullOrEmpty(collection["WorksName"])) { ViewBag.WorksName = collection["WorksName"].ToString(); } ViewBag.AuthorNoList = ""; if (!string.IsNullOrEmpty(collection["AuthorNoList"])) { value.AuthorNoList = collection["AuthorNoList"].Split(',').ToList(); ViewBag.AuthorNoList = collection["AuthorNoList"].ToString(); } ViewBag.MinePrice = ""; if (!string.IsNullOrEmpty(collection["MinePrice"])) { value.MinePrice = Convert.ToInt32(collection["MinePrice"]); ViewBag.MinePrice = value.MinePrice.ToString(); } ViewBag.MaxPrice = ""; if (!string.IsNullOrEmpty(collection["MaxPrice"])) { value.MaxPrice = Convert.ToInt32(collection["MaxPrice"]); ViewBag.MaxPrice = value.MaxPrice.ToString(); } var _value = value.Search(1, take); //多取一,若有表示有下一頁 if (_value.Count == (take + 1)) { ViewBag.pn = 1; _value.RemoveAt(take); } else { ViewBag.pn = 0; } ViewBag.pi = 0; for (int i = 0; i < _value.Count; i++) { model.Add(new WorksViewModel() { WorksNo = _value[i].WorksNo, WorksName = _value[i].WorksName, AuthorsName = _value[i].AuthorsName, YearStart = _value[i].YearStart, YearEnd = _value[i].YearEnd, Cost = _value[i].Cost, Price = _value[i].Price, Material = _value[i].MaterialsName }); } MenuModel mm = new MenuModel(); List <SelectListItem> WorksAuthors = new List <SelectListItem>(); var _WorksAuthors = AuthorsModel.GetAuthorList(); for (int i = 0; i < _WorksAuthors.Count; i++) { WorksAuthors.Add(new SelectListItem() { Text = _WorksAuthors[i].AuthorsCName, Value = _WorksAuthors[i].AuthorsNo.ToString() }); } ViewBag.WorksAuthors = WorksAuthors; var MeunOrderList = new Dictionary <string, string>(); foreach (var item in Enum.GetValues(typeof(MenuModel.WorkOrderbyTypeEnum))) { MeunOrderList.Add(item.ToString(), item.ToString()); } ViewBag.MeunOrderList = new SelectList(MeunOrderList, "Key", "Value", ViewBag.OrderbyType); //setSortDropDown(_MeunOrderbyTypeEnum); ViewBag.pt = take.ToString(); return(View(model)); }
public ActionResult Filter(string id = "") { AdSearchViewModel model = new AdSearchViewModel(); if (!string.IsNullOrEmpty(id)) { var value = PackagesModel.GetPackageDetail(id); model = JsonConvert.DeserializeObject <AdSearchViewModel>(value.SearchJson); if (model != null) { model.Budget = value.Budget; model.PG_Name = value.PackagesName; model.PG_No = value.PackagesNo; } else { model = new AdSearchViewModel(); } } MenuModel mm = new MenuModel(); List <SelectListItem> Authorsitems = new List <SelectListItem>(); var _AuthorNoList = AuthorsModel.GetAuthorList(); for (int i = 0; i < _AuthorNoList.Count; i++) { Authorsitems.Add(new SelectListItem() { Text = _AuthorNoList[i].AuthorsCName, Value = _AuthorNoList[i].AuthorsNo.ToString() }); } ViewBag.AuthorNoList = Authorsitems; List <SelectListItem> WorksStyleitems = new List <SelectListItem>(); var _WorksStyleList = mm.GetMenu(MenuModel.MenuClassEnum.Style); for (int i = 0; i < _WorksStyleList.Count; i++) { WorksStyleitems.Add(new SelectListItem() { Text = _WorksStyleList[i].MenuName, Value = _WorksStyleList[i].MenuID.ToString() }); } ViewBag.StyleNoList = WorksStyleitems; List <SelectListItem> WorksGenreitems = new List <SelectListItem>(); var _WorksGenreList = mm.GetMenu(MenuModel.MenuClassEnum.Genre); for (int i = 0; i < _WorksGenreList.Count; i++) { WorksGenreitems.Add(new SelectListItem() { Text = _WorksGenreList[i].MenuName, Value = _WorksGenreList[i].MenuID.ToString() }); } ViewBag.GenreNoList = WorksGenreitems; ViewBag.GradedNoList = new List <SelectListItem>(); return(View(model)); }
// GET: Author/Delete/5 public ActionResult Delete(int id) { AuthorsModel.Delete(id); return(RedirectToAction("Index")); }
public static void 新增藝術家(匯入資料 _匯入資料) { if (!_匯入資料.藝術家中文名稱.Contains(";")) { string 中文名 = 處理文字(_匯入資料.藝術家中文名稱); string 外文名 = 處理文字(_匯入資料.藝術家外文名稱); List <string> _藝術家標籤 = 分割文字(_匯入資料.藝術家標籤); List <string> _藝術家區域 = 分割文字(_匯入資料.藝術家區域); List <string> AreaNoList = new List <string>(); AreaNoList.Add("1"); List <string> TagNoList = new List <string>(); TagNoList.Add("1"); using (var context = new EG_MagicCubeEntities()) { var _Authors = context.Authors.AsQueryable().Where(c => c.AuthorsCName == 中文名).FirstOrDefault(); if (_Authors == null) { var 標籤List = 匯入資料List.Where(c => c.藝術家中文名稱 == _匯入資料.藝術家中文名稱).Select(c => c.藝術家標籤).ToList(); if (標籤List != null && 標籤List.Count > 0) { foreach (string str in 標籤List) { _藝術家標籤 = 處理標籤(_藝術家標籤, str, true); } } var 區域List = 匯入資料List.Where(c => c.藝術家中文名稱 == _匯入資料.藝術家中文名稱).Select(c => c.藝術家區域).ToList(); if (區域List != null && 區域List.Count > 0) { foreach (string str in 區域List) { _藝術家區域 = 處理標籤(_藝術家區域, str, true); } } if (_藝術家標籤 != null && _藝術家標籤.Count > 0) { var _AuthorsTagArray = context.Menu_AuthorsTag.AsQueryable().Where(c => _藝術家標籤.Contains(c.AuthorsTagName)).Select(c => c.AuthorsTagNo).ToList(); if (_AuthorsTagArray != null && _AuthorsTagArray.Count > 0) { TagNoList = _AuthorsTagArray.Select(c => c.ToString()).ToList(); } } if (_藝術家區域 != null && _藝術家區域.Count > 0) { var _AuthorsAreaArray = context.Menu_AuthorsArea.AsQueryable().Where(c => _藝術家區域.Contains(c.AuthorsAreaName)).Select(c => c.AuthorsAreaNo).ToList(); if (_AuthorsAreaArray != null && _AuthorsAreaArray.Count > 0) { AreaNoList = _AuthorsAreaArray.Select(c => c.ToString()).ToList(); } } AuthorsModel _AuthorsModel = new AuthorsModel(); _AuthorsModel.AuthorsCName = 中文名; _AuthorsModel.AuthorsEName = 外文名; _AuthorsModel.ModifyUser = "******"; _AuthorsModel.CreateUser = "******"; _AuthorsModel.AuthorsTagNo_InputString = TagNoList; _AuthorsModel.AuthorsAreaNo_InputString = AreaNoList; Console.WriteLine(JsonConvert.SerializeObject(_AuthorsModel)); _AuthorsModel.Create(); } } } }