Пример #1
0
        public ActionResult EditGallery(int id)
        {
            if (IsValidSessions())
            {
                ViewBag.ServiceTabFileList = EService.GetServiceTabFileAdmin(0, 5, id).ToList();
                TempData["Count"] = EService.GetCountServiceTabFileAdmin(id);
                validationEditGalleryTab validationEditGalleryTab = new validationEditGalleryTab() { id = id, TabName = _RService.DetailsServiceTab(id).Name };
                ViewBag.PageNumber = 1;

                ServiceTab ServiceTab = _RService.DetailsServiceTab(validationEditGalleryTab.id);
                ViewBag.alts = string.Join("|", ServiceTab.ServiceTabFile.Select(_ => _.Alt).ToArray());

                return View(validationEditGalleryTab);
            }
            else
                return RedirectToAction("Login", "Home");
        }
Пример #2
0
        public ActionResult EditGallery(validationEditGalleryTab validationEditGalleryTab, string alts)
        {
            if (IsValidSessions())
            {
                //  string filename = "";
                bool isok = true;
                GetFileExtension Ext = new GetFileExtension();
                ServiceTab ServiceTab = _RService.DetailsServiceTab(validationEditGalleryTab.id);

                if (ServiceTab.ServiceTabFile != null)
                {
                    var altsArray = string.IsNullOrEmpty(alts) ? new string[0] { } : alts.Split(new string[] { "|" }, StringSplitOptions.None);
                    foreach (var item in ServiceTab.ServiceTabFile)
                    {
                        if (altsArray.Length > 0)
                        {
                            foreach (var i in altsArray)
                            {
                                var j = i.Split(new string[] { ":" }, StringSplitOptions.None);

                                if (int.Parse(j[0]) == item.Id)
                                {
                                    item.Alt = j[1];
                                }
                            }
                        }
                    }
                }

                if (isok)
                {
                    ServiceTab.Name = validationEditGalleryTab.TabName;
                    ServiceTab.ModifiedDate = DateTime.Now.Date;

                    _RService.SaveServiceTab(ServiceTab);
                    TempData["result"] = "OK";
                    TempData["Message"] = "عملیات با موفقیت انجام شد.";
                    return RedirectToAction("ProductList");
                }
                ViewBag.ServiceTabFileList = EService.GetServiceTabFileAdmin(0, 5, validationEditGalleryTab.id).ToList();
                TempData["Count"] = EService.GetCountServiceTabFileAdmin(validationEditGalleryTab.id);
                ViewBag.PageNumber = 1;
                return View();
            }
            else
                return RedirectToAction("Login", "Home");
        }