Пример #1
0
        public ActionResult SaveData(BaseCodeChangeViewModel basecodes)
        {
            if (basecodes.updated != null)
            {
                foreach (var updated in basecodes.updated)
                {
                    _baseCodeService.Update(updated);
                }
            }
            if (basecodes.deleted != null)
            {
                foreach (var deleted in basecodes.deleted)
                {
                    _baseCodeService.Delete(deleted);
                }
            }
            if (basecodes.inserted != null)
            {
                foreach (var inserted in basecodes.inserted)
                {
                    _baseCodeService.Insert(inserted);
                }
            }
            _unitOfWork.SaveChanges();

            return(Json(new { Success = true }, JsonRequestBehavior.AllowGet));
        }
Пример #2
0
        public async Task <ActionResult> SaveData(BaseCodeChangeViewModel basecodes)
        {
            if (basecodes.updated != null)
            {
                foreach (var item in basecodes.updated)
                {
                    _baseCodeService.Update(item);
                }
            }
            if (basecodes.deleted != null)
            {
                foreach (var item in basecodes.deleted)
                {
                    _baseCodeService.Delete(item);
                }
            }
            if (basecodes.inserted != null)
            {
                foreach (var item in basecodes.inserted)
                {
                    _baseCodeService.Insert(item);
                }
            }
            await _unitOfWork.SaveChangesAsync();

            return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
        }
        //[ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            BaseCode baseCode = _baseCodeService.Find(id);

            _baseCodeService.Delete(baseCode);
            _unitOfWork.SaveChanges();
            if (Request.IsAjaxRequest())
            {
                return(Json(new { success = true }, JsonRequestBehavior.AllowGet));
            }
            DisplaySuccessMessage("Has delete a BaseCode record");
            return(RedirectToAction("Index"));
        }