Пример #1
0
        public SystemWorkPlaceVM(SystemWorkPlace bo)
        {
            this.ID = bo.ID;
            this.Name = bo.Name;
            this.Description = bo.Description;
            this.SortCode = bo.SortCode;

            if (bo.AppInfo != null)
            {
                this.ApplicationInfo = new PlainFacadeItem()
                {
                    ID = bo.AppInfo.ID.ToString(),
                    Name = bo.AppInfo.Name,
                    DisplayName = bo.AppInfo.Name + "(" + bo.AppInfo.AppVersion + ")",
                    SortCode = bo.AppInfo.SortCode
                };
            }

            if (bo.SystemWorkSections != null)
            {
                this.SystemWorkSetionItems = new List<PlainFacadeItem>();
                foreach (var item in bo.SystemWorkSections)
                {
                    var pItem = new PlainFacadeItem()
                    {
                        ID = item.ID.ToString(),
                        Name = item.Name,
                        Description = item.Description,
                        SortCode = item.SortCode
                    };
                    this.SystemWorkSetionItems.Add(pItem);
                }
            }
        }
Пример #2
0
        public ActionResult CreateOrEdit(Guid id)
        {
            bool isNew = false;
            var bo = _Service.GetSingle(id);
            if (bo == null)
            {
                bo = new SystemWorkPlace();
                bo.ID= id;
                isNew = true;
            }
            var boVM = new SystemWorkPlaceVM(bo);
            var editor = PageComponentRepository<SystemWorkPlaceVM>.CreateOrEditDialog(boVM, isNew);

            return Json(editor);
        }
Пример #3
0
        public ActionResult Save(SystemWorkPlaceVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _Service.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo = new SystemWorkPlace();
                    bo.ID = boVM.ID;
                }

                var appID = Assembly.GetExecutingAssembly().ManifestModule.ModuleVersionId;

                var appInfo = _Service.GetSingleRelevance<ApplicationInformation>(appID);
                if(appInfo==null)
                {
                    appInfo = new ApplicationInformation();
                    appInfo.ID = appID;
                    appInfo.AppID = appID;
                    appInfo.Name = "";
                    appInfo.Description = "";
                    appInfo.SortCode = "001";
                    _Service.AddRelevance<ApplicationInformation>(appInfo);
                    _Service.Save();
                }
                boVM.MapToBo(bo, appInfo);
                _Service.AddOrEditAndSave(bo);

                return Json(PageComponentRepository<SystemWorkPlaceVM>.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<SystemWorkPlaceVM>.UpdateCreateOrEditDialog(boVM, false, vItems).InnerHtmlContent;
                return Json(editor);
            }
        }
Пример #4
0
 public void MapToBo(SystemWorkPlace bo, ApplicationInformation appInfo)
 {
     bo.Name = this.Name;
     bo.Description = this.Description;
     bo.SortCode = this.SortCode;
     bo.AppInfo = appInfo;
 }