Beispiel #1
0
        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));
            }
        }
Beispiel #2
0
 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));
     }
 }