Exemplo n.º 1
0
        public ActionResult Edit(string id, string parameter)
        {
            var item = new CmsArtical();

            if (!string.IsNullOrEmpty(id))
            {
                item = _iCmsArticalService.GetById(id);
            }
            ViewBag.Category      = _iCmsCategoryService.GetAll(a => a.Enable && a.SystemId == parameter).FirstOrDefault();
            ViewBag.CmsCategoryId = new SelectList(_iCmsCategoryService.GetAll(a => a.Enable && a.SystemId.Substring(0, 3) == parameter && a.SystemId.Length > 3).Select(a => new { a.Id, a.Name }),
                                                   "Id", "Name", item.CmsCategoryId);
            return(View(item));
        }
Exemplo n.º 2
0
        public async Task <ActionResult> Edit(string id, string parameter, CmsArtical collection)
        {
            if (!ModelState.IsValid)
            {
                Edit(id, parameter);
                return(View(collection));
            }
            if (string.IsNullOrEmpty(collection.CmsCategoryId))
            {
                var categoryId = _iCmsCategoryService.GetAll(a => a.SystemId == parameter).Select(a => a.Id).FirstOrDefault();
                collection.CmsCategoryId = categoryId;
            }

            _iCmsArticalService.Save(id, collection);

            await _unitOfWork.CommitAsync();

            return(new EditSuccessResult(id));
        }