Exemplo n.º 1
0
 public FileTypeVM(FileType bo)
 {
     this.ID = bo.ID;
     this.Name = bo.Name;
     this.Description = bo.Description;
     this.SortCode = bo.SortCode;
 }
Exemplo n.º 2
0
        public ActionResult CreateOrEdit(Guid id)
        {
            bool isNew = false;
            var bo = _Service.GetSingle(id);
            if (bo == null)
            {
                bo = new FileType();
                bo.ID = id;
                isNew = true;
            }
            var boVM = new FileTypeVM(bo);
            var editor = PageComponentRepository<FileTypeVM>.CreateOrEditDialog(boVM, isNew);

            return Json(editor);
        }
Exemplo n.º 3
0
        public ActionResult Save(FileTypeVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _Service.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo = new FileType();
                    bo.ID = boVM.ID;
                }

                boVM.MapToBo(bo);
                _Service.AddOrEditAndSave(bo);

                return Json(PageComponentRepository<FileTypeVM>.SaveOK(true, "1", ""));
            }
            else
            {
                var vItems = new List<ValidatorResult>();
                foreach (var item in ModelState)
                {
                    if (item.Value.Errors != null)
                    {
                        foreach (var vItem in item.Value.Errors)
                        {
                            var errItem = new ValidatorResult();
                            errItem.Name = item.Key;
                            errItem.ErrorMessage = vItem.ErrorMessage;
                            vItems.Add(errItem);
                        }
                    }
                }

                var editor = PageComponentRepository<FileTypeVM>.UpdateCreateOrEditDialog(boVM, false, vItems).InnerHtmlContent;
                return Json(editor);
            }
        }
Exemplo n.º 4
0
 public void MapToBo(FileType bo)
 {
     bo.Name = this.Name;
     bo.Description = this.Description;
     bo.SortCode = this.SortCode;
 }