public ActionResult Create(FlashBannerFormModel model, HttpPostedFileBase uploadPicture) { if (ModelState.IsValid) { var item = Mapper.Map <FlashBannerFormModel, FlashBanner>(model); if (uploadPicture != null && uploadPicture.ContentLength > 0) { if (model.TypeId == 1) { item.Banner += "|" + SaveFile(uploadPicture, "flashBanners", item.Banner); } else { item.Banner = SaveFile(uploadPicture, "flashBanners", item.Banner); } } int maxOrder = GetSession.Query <FlashBanner>() .Max(x => (int?)x.BannerOrder) ?? 0; item.BannerOrder = maxOrder + 1; GetSession.Save(item); return(RedirectToAction("Index")); } model.InitMembers(); return(View(model)); }
private void AddCategoryPage(Page page) { int maxOrder = GetSession.Query <Page>() .Where(x => x.Parent.Id == page.Parent.Id && x.SectionId == page.SectionId) .Max(x => (int?)x.PageOrder) ?? 0; page.PageOrder = maxOrder + 1; page.IsInternal = true; page.UpdatedDate = DateTime.Now; GetSession.Save(page); //return RedirectToAction("Index", new { model.ParentId, model.SectionId }); }
public ActionResult Create(PageFormModel model, FormCollection coll) { var item = Mapper.Map <PageFormModel, Page>(model); Page parent = null; if (model.ParentId.HasValue) { parent = GetSession.Get <Page>(model.ParentId); item.Parent = parent; } int maxOrder = GetSession.Query <Page>() .Where(x => x.Parent == parent && x.SectionId == model.SectionId ).Max(x => (int?)x.PageOrder) ?? 0; if (item.TypeId == 999) { item.PageTemplate = "tv"; item.Iframelink1DelayTime = coll["Iframelink1"].ToString().Split(',')[1]; item.Iframelink2DelayTime = coll["Iframelink2"].ToString().Split(',')[1]; item.Iframelink3DelayTime = coll["Iframelink3"].ToString().Split(',')[1]; item.Iframelink4DelayTime = coll["Iframelink4"].ToString().Split(',')[1]; item.Iframelink5DelayTime = coll["Iframelink5"].ToString().Split(',')[1]; } if (item.TypeId == 001) { } item.PageOrder = maxOrder + 1; item.IsInternal = true; item.UpdatedDate = DateTime.Now; GetSession.Save(item); return(RedirectToAction("Index", new { model.ParentId, model.SectionId })); }