public ActionResult AddNotice() { var categoryRepo = new CategoryRepository(); var allCategory = categoryRepo.GetAllCategory(); var noticePlaceRepo = new NoticePlaceRepository(); var allNoticePlace = noticePlaceRepo.GetAllNoticePlace(); var result = new NewNoticeViewModel(); var categoryListTemporary = new List<SelectListItem>(); foreach (var category in allCategory) { categoryListTemporary.AddRange(category.SubCategory.Select(x => new SelectListItem { Text = string.Format("{0}, {1}", category.Name, x.Name), Value = x.Id.ToString() })); } result.CategoryList = categoryListTemporary; result.NoticePlaceList = allNoticePlace.Select(x => new SelectListItem { Text = string.Format("{0}, {1}", x.Province, x.City), Value = x.Id.ToString() }).OrderBy(x => x.Text); return View(result); }
public ActionResult ShowNoticeDetails(int noticeId) { var categoryRepo = new CategoryRepository(); var allCategory = categoryRepo.GetAllCategory(); var noticeRepo = new NoticeRepository(); var currentNotice = noticeRepo.GetNoticeById(noticeId); var result = new NoticeDetailsViewModel(); result.CategoriesList = allCategory; result.Notice = currentNotice; return View(result); }
public ActionResult Index(Nullable<int> categoryId = null) { var categoryRepo = new CategoryRepository(); var allCategory = categoryRepo.GetAllCategory(); var noticeRepo = new NoticeRepository(); var noticesList = new List<NoticeRepo>(); if (categoryId == null) noticesList = noticeRepo.GetAllNotices(); else noticesList = noticeRepo.GetNoticesByCategoryId(categoryId.Value); var result = new HomeViewModel(); result.CategoriesList = allCategory; result.NoticesList = noticesList; result.SelectedCategoryId = categoryId; return View(result); }
public ActionResult EditNotice(int noticeId) { var categoryRepo = new CategoryRepository(); var allCategory = categoryRepo.GetAllCategory(); var noticePlaceRepo = new NoticePlaceRepository(); var allNoticePlace = noticePlaceRepo.GetAllNoticePlace(); var result = new NewNoticeViewModel(); var categoryListTemporary = new List<SelectListItem>(); foreach (var category in allCategory) { categoryListTemporary.AddRange(category.SubCategory.Select(x => new SelectListItem { Text = string.Format("{0}, {1}", category.Name, x.Name), Value = x.Id.ToString() })); } result.CategoryList = categoryListTemporary; result.NoticePlaceList = allNoticePlace.Select(x => new SelectListItem { Text = string.Format("{0}, {1}", x.Province, x.City), Value = x.Id.ToString() }).OrderBy(x => x.Text); var noticeRepo = new NoticeRepository(); var currentNotice = noticeRepo.GetNoticeById(noticeId); result.Title = currentNotice.Title; result.Amount = currentNotice.Amount.ToString(); result.Description = currentNotice.Description; //result.ExpireTo = currentNotice.Title; result.SelectedCategoryId = currentNotice.CategoryId.ToString(); result.NoticePlaceId = currentNotice.NoticePlaceId.ToString(); result.Id = currentNotice.Id; return View(result); }