public ProductGalleryController() { vm = new ProductGalleryVM(); _repoPosition = new PositionGalleryDAO(); _repoSectionGallery = new SectionGalleryDAO(); _repoSectionContent = new SectionContentDAO(); }
ProductGalleryVM ExcuteActionCommonView(ProductGalleryVM obj) { obj.SectionGalleries.CollectionImage = obj.SectionGalleries.CollectionImage.Substring(0, obj.SectionGalleries.CollectionImage.Length - 1); obj.SectionGalleries.CreatedOn = DateTime.Now; obj.SectionContents.CreatedOn = DateTime.Now; obj.SectionContents.UpdateOn = DateTime.Now; return(obj); }
public ActionResult Edit(ProductGalleryVM obj, string typePage) { try { using (TransactionScope scope = new TransactionScope()) { obj.SectionGalleries.PositionGalleryID = _repoPosition.GetItemByPosName(typePage).PositionGalleryID; obj.SectionGalleries.CollectionImage = obj.SectionGalleries.CollectionImage.Substring(0, obj.SectionGalleries.CollectionImage.Length - 1); obj.SectionContents.PositionGalleryID = obj.SectionGalleries.PositionGalleryID; obj.SectionContents.UpdateOn = DateTime.Now; _repoSectionContent.Edit(obj.SectionContents); // if (typePage == PositionTab.Overview) // { obj.ListSectionGalleries.Add(obj.SectionGalleries); if (obj.CollectUrlGallery != null && obj.CollectUrlGallery.Any()) { obj.ListSectionGalleries.Add(new Fly_SectionGallery() { CollectionImage = obj.CollectUrlGallery.Substring(0, obj.CollectUrlGallery.Length - 1), CreatedOn = DateTime.Now, PositionGalleryID = _repoPosition.GetItemByPosName(PositionTab.Gallery).PositionGalleryID, ProductID = obj.SectionContents.ProductID }); foreach (var listSectionGallery in obj.ListSectionGalleries) { _repoSectionGallery.Edit(listSectionGallery); } } // } // else // { // _repoSectionGallery.Edit(obj.SectionGalleries); // } scope.Complete(); scope.Dispose(); } string routeDirect = typePage == PositionTab.Overview ? "/Administrator/ProductGallery/overview" : "/Administrator/ProductGallery/featuries"; return(Redirect(routeDirect)); } catch (Exception e) { return(View(e.Message)); } }
public ActionResult Edit(int id, ProductGalleryVM obj) { try { obj.SectionContents.UpdateOn = DateTime.Now; _repository.Edit(obj.SectionContents); return(RedirectToAction("Index")); } catch (Exception e) { return(View(e.Message)); } }
public ActionResult Delete(int id, ProductGalleryVM obj) { try { // TODO: Add delete logic here return(RedirectToAction("Index")); } catch { return(View()); } }
public ActionResult Create(ProductGalleryVM obj) { try { // TODO: Add insert logic here obj.SectionContents.CreatedOn = DateTime.Now; obj.SectionContents.UpdateOn = DateTime.Now; obj.SectionContents.PositionGalleryID = obj.PositionGalleries.PositionGalleryID; _repository.Add(obj.SectionContents); return(RedirectToAction("Index")); } catch (Exception e) { return(View(e.Message)); } }
public ActionResult Overview(ProductGalleryVM obj) { try { using (TransactionScope scope = new TransactionScope()) { // TODO: Add insert logic here obj = ExcuteActionCommonView(obj); obj.SectionGalleries.PositionGalleryID = _repoPosition.GetItemByPosName(PositionTab.Overview).PositionGalleryID; obj.SectionContents.PositionGalleryID = obj.SectionGalleries.PositionGalleryID; obj.ListSectionGalleries.Add(obj.SectionGalleries); if (obj.CollectUrlGallery != null && obj.CollectUrlGallery.Any()) { obj.ListSectionGalleries.Add(new Fly_SectionGallery() { CollectionImage = obj.CollectUrlGallery.Substring(0, obj.CollectUrlGallery.Length - 1), CreatedOn = DateTime.Now, PositionGalleryID = _repoPosition.GetItemByPosName(PositionTab.Gallery).PositionGalleryID, ProductID = obj.SectionContents.ProductID }); } _repoSectionContent.Add(obj.SectionContents); foreach (var listSectionGallery in obj.ListSectionGalleries) { _repoSectionGallery.Add(listSectionGallery); } scope.Complete(); scope.Dispose(); } return(RedirectToAction("Index")); } catch (Exception e) { return(View(e.Message)); } }
public JsonResult GetFeatureTab(string type) { ProductGalleryVM vm = new ProductGalleryVM(); IRepositrySectionContent <Fly_SectionContent> _repoSectionContent = new SectionContentDAO(); try { vm.ListSectionContents = _repoSectionContent.getAllItems().Where(x => x.Fly_PositionGallery.PositionName_EN.Equals(type)).ToList(); return(Json(vm.ListSectionContents.Select(x => new { x.ProductID, x.Fly_Product.Name, x.Fly_PositionGallery.PositionName, x.FullDescription, x.FullDescription_EN }), JsonRequestBehavior.AllowGet)); } catch (Exception e) { return(Json(e.Message)); } }
public ActionResult Featuries(ProductGalleryVM obj) { try { using (TransactionScope scope = new TransactionScope()) { // TODO: Add insert logic here obj = ExcuteActionCommonView(obj); obj.SectionGalleries.PositionGalleryID = _repoPosition.GetItemByPosName(PositionTab.Feature).PositionGalleryID; obj.SectionContents.PositionGalleryID = obj.SectionGalleries.PositionGalleryID; _repoSectionContent.Add(obj.SectionContents); _repoSectionGallery.Add(obj.SectionGalleries); scope.Complete(); scope.Dispose(); } return(RedirectToAction("Index")); } catch (Exception e) { return(View(e.Message)); } }
public SpecController() { vm = new ProductGalleryVM(); _repository = new SectionContentDAO(); _repoPositionPos = new PositionGalleryDAO(); }