public ActionResult SermonsbyCategory(string name) { var sermonscategory = _sermonServices.GetSermons().Where(vv => vv.SermonCategory.SermonName == name); var svm = new SermonViewModel { Sermons = sermonscategory, SermonCat = name }; return(View("Index", svm)); }
public ActionResult SermonsbyCategory(string name) { var sermonscategory = _uow.Sermons.Find(sc => sc.SermonCategory.SermonName == name); var svm = new SermonViewModel { Sermons = sermonscategory, //SermonCategory = name SermonCat = name }; return(View("Index", svm)); }
public void Add(SermonViewModel viewModel) { _repository.Add(new Sermon { CreationDate = DateTime.Now, IsItDeleted = false, Status = true, SiteLanguage = viewModel.SiteLanguage, Title = viewModel.Title, Content = viewModel.Content, Image = "/Areas/Login/Assets/images/" + viewModel.Image, }); }
public void Update(SermonViewModel viewModel) { var sermons = _repository.Get(x => x.Id == viewModel.Id); sermons.Status = viewModel.Status; sermons.DateOfUpdate = DateTime.Now; sermons.IsItDeleted = viewModel.IsItDeleted; sermons.SiteLanguage = viewModel.SiteLanguage; sermons.Title = viewModel.Title; sermons.Content = viewModel.Content; sermons.Image = viewModel.Image; _repository.Update(sermons); }
public ActionResult Index() { var sermon = _uow.Sermons.GetAll(); ViewBag.SermonCategory = _uow.SermonCategories.GetAll().Select(r => new SermonCategory { SermonName = r.SermonName, SermonDescription = r.SermonDescription }); var sermonCat = _uow.SermonCategories.GetAll(); var svm = new SermonViewModel { Sermons = sermon, SermonCategory = sermonCat, SermonCat = "" }; return(View(svm)); }
// GET: Sermon public ActionResult Index() { var sermon = _sermonServices.GetSermons().OrderBy(n => n.SermonDate); ViewBag.SermonCategory = _context.SermonCategories.ToList().Select(r => new SermonCategoryModel(r) { SermonDescription = r.SermonDescription, SermonName = r.SermonName }); var sermonCat = _context.SermonCategories.ToList(); var svm = new SermonViewModel { Sermons = sermon, SermonCategorss = sermonCat, SermonCat = "" }; return(View(svm)); }
public ActionResult SermonSave(SermonViewModel viewModel, HttpPostedFileBase Image) { SessionKontrol(); if (_users != null) { try { if (viewModel.Image == null) { viewModel.Image = "0"; } var isValid = Validate(viewModel, new SermonValidator(), ModelState); if (isValid) { if (viewModel.Id == 0) { UploadFiles(Image); viewModel.Image = imagename; viewModel.Status = true; _SermonServices.Add(viewModel); } else { var getimg = _SermonServices.Get(viewModel.Id).Image; if (viewModel.Image == "0") { viewModel.Image = getimg; viewModel.Status = true; _SermonServices.Update(viewModel); } else { UploadFiles(Image); viewModel.Image = "/Areas/Login/Assets/images/" + imagename; _SermonServices.Update(viewModel); } } } else { if (viewModel.Id == 0) { return(View("sermonadd", viewModel)); } else { return(View("sermondetail", viewModel)); } } } catch (Exception) { return(View(ViewForm, viewModel)); } _unitOfWork.SaveChanges(); return(RedirectToAction("SermonList", "Sermon")); } else { return(RedirectToAction("Index", "Login")); } }