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

            return Json(editor);
        }
Beispiel #3
0
 public void MapToBo(JobTitle bo)
 {
     bo.Name = this.Name;
     bo.Description = this.Description;
     bo.SortCode = this.SortCode;
 }
Beispiel #4
0
        public ActionResult Save(JobTitleVM boVM)
        {
            if (ModelState.IsValid)
            {
                var bo = _Service.GetSingle(boVM.ID);
                if (bo == null)
                {
                    bo = new JobTitle();
                    bo.ID = boVM.ID;
                }

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

                return Json(PageComponentRepository<JobTitleVM>.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<JobTitleVM>.UpdateCreateOrEditDialog(boVM, false, vItems).InnerHtmlContent;
                return Json(editor);
            }
        }