Пример #1
0
        //
        // GET: /Platform/SysHelp/Edit/5
        public ActionResult Edit(Guid? id)
        {
            var item = new SysHelp();
            if (id.HasValue)
            {
                item = _sysHelp.GetById(id.Value);
            }

            return View(item);
        }
Пример #2
0
        //
        // GET: /Platform/SysHelp/Edit/5

        public ActionResult Edit(Guid? id)
        {
            var item = new SysHelp();
            if (id.HasValue)
            {
                item = _sysHelp.GetById(id.Value);
            }
            if (item.SysHelpImages != null)
                ViewBag.SysHelpImagesUrl = item.SysHelpImages.Select(a => a.Url).ToList();
            return View(item);
        }
Пример #3
0
        public ActionResult Edit(Guid? id, SysHelp collection, IEnumerable<string> sysHelpImagesUrl)
        {
            if (!ModelState.IsValid)
            {
                Edit(id);
                return View(collection);
            }

            _sysHelp.Save(id, collection);

            _unitOfWork.Commit();

            return RedirectToAction("Index");
        }
Пример #4
0
        public ActionResult Edit(Guid? id, SysHelp collection, IEnumerable<string> sysHelpImagesUrl)
        {
            if (!ModelState.IsValid)
            {
                Edit(id);
                return View(collection);
            }

            if (id.HasValue)
            {
                _sysHelpImage.Delete(a => a.SysHelpId.Equals(id.Value));
            }

            _sysHelp.Save(id, collection);

            if (sysHelpImagesUrl != null)
            {
                var sysHelpImages =
                    sysHelpImagesUrl.Where(a => !string.IsNullOrEmpty(a))
                                    .Select(
                                        sysHelpImageUrl =>
                                        new SysHelpImage { SysHelpId = collection.Id, Url = sysHelpImageUrl })
                                    .ToList();
                sysHelpImages.ForEach(a => _sysHelpImage.Add(a));
            }

            _unitOfWork.Commit();

            return RedirectToAction("Index");
        }