コード例 #1
0
        /// for Add Option in Select(DropDpownList)
        /// input: objectname, return:Check if user allowed to ad to table and return List of Columns (form or grid)
        public ActionResult GetColumns(string objectname)
        {
            byte    version  = 0;
            PageDiv page     = _hrUnitOfWork.PagesRepository.GetPageType(CompanyId, objectname, version);
            bool    isAllowd = _hrUnitOfWork.MenuRepository.IsAllowTable(page.MenuId, UserName);

            if (!isAllowd)
            {
                return(Json("false," + MsgUtils.Instance.Trls("DontHavePermissionAddTable"), JsonRequestBehavior.AllowGet));
            }

            List <FormList> qualGroups = new List <FormList>();

            if (objectname == "Qualifications")
            {
                qualGroups = _hrUnitOfWork.QualificationRepository.GetQualGroups().Select(q => new FormList {
                    id = q.Id, name = q.Name
                }).ToList();
            }

            if (page.DivType == "Form")
            {
                var FormColumns = _hrUnitOfWork.PagesRepository.GetFormColumnInfo(CompanyId, objectname, version, Language)
                                  .Where(c => c.required);
                return(Json(new { columns = FormColumns, qualGroupLst = qualGroups }, JsonRequestBehavior.AllowGet));
            }
            var GridColumns = _hrUnitOfWork.PagesRepository.GetColumnInfo(CompanyId, objectname, version, Language)
                              .Where(c => c.Required && c.ColumnType != "button" && !(c.ColumnName == "Code" && c.DataType == "number")).OrderBy(c => c.ColumnOrder);

            return(Json(new { columns = GridColumns, qualGroupLst = qualGroups }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult DeletePage(IEnumerable <PageDivViewModel> models)
        {
            var           datasource = new DataSource <PageDivViewModel>();
            List <string> keys       = new List <string>();

            for (int i = 0; i < models.Count(); i++)
            {
                var x = models.ElementAtOrDefault(i);
                keys.Add(x.CompanyId + x.ObjectName + x.Version + Language);
            }


            if (ModelState.IsValid)
            {
                foreach (PageDivViewModel model in models)
                {
                    var page = new PageDiv
                    {
                        Id = model.Id
                    };

                    AutoMapper(new Models.AutoMapperParm
                    {
                        Source     = page,
                        ObjectName = "PageDivs",
                        Transtype  = TransType.Delete
                    });


                    _hrUnitOfWork.PageEditorRepository.Remove(page);

                    foreach (ColumnTitle title in _hrUnitOfWork.Repository <ColumnTitle>().Where(t => t.CompanyId == model.CompanyId && t.ObjectName == model.ObjectName && t.Version == model.Version).ToList())
                    {
                        _hrUnitOfWork.PageEditorRepository.Remove(title);
                    }
                    foreach (RoleColumns role in _hrUnitOfWork.Repository <RoleColumns>().Where(r => r.CompanyId == model.CompanyId && r.ObjectName == model.ObjectName && r.Version == model.Version).ToList())
                    {
                        _hrUnitOfWork.PageEditorRepository.Remove(role);
                    }
                }

                datasource.Errors = SaveChanges(Language);
                datasource.Total  = models.Count();
            }

            datasource.Data = models;

            if (datasource.Errors.Count() > 0)
            {
                return(Json(datasource));
            }
            else
            {
                for (int i = 0; i < keys.Count; i++)
                {
                    if (_hrUnitOfWork.PagesRepository.CacheManager.IsSet(keys[i]))
                    {
                        _hrUnitOfWork.PagesRepository.CacheManager.Remove(keys[i]);
                    }
                }
                return(Json(datasource.Data));
            }
        }
コード例 #3
0
        public ActionResult CreateForm(IEnumerable <PageDivViewModel> models)
        {
            var result = new List <PageDiv>();

            var datasource = new DataSource <PageDivViewModel>();

            datasource.Data  = models;
            datasource.Total = models.Count();

            if (ModelState.IsValid)
            {
                if (ServerValidationEnabled)
                {
                    var errors = _hrUnitOfWork.MenuRepository.Check(new CheckParm
                    {
                        CompanyId    = CompanyId,
                        ObjectName   = "PageDivs",
                        TableName    = "PageDivs",
                        ParentColumn = "CompanyId",
                        Columns      = Models.Utils.GetModifiedRows(ModelState),
                        Culture      = Language
                    });

                    if (errors.Count() > 0)
                    {
                        datasource.Errors = errors;
                        return(Json(datasource));
                    }
                }

                foreach (PageDivViewModel p in models)
                {
                    var page = new PageDiv
                    {
                        ObjectName = p.ObjectName,
                        TableName  = p.TableName,
                        DivType    = "Form",
                        Title      = p.Title,
                        MenuId     = p.MenuId,
                        CompanyId  = CompanyId
                    };

                    result.Add(page);
                    _hrUnitOfWork.PageEditorRepository.AddFieldSetColumns(page);
                }

                datasource.Errors = SaveChanges(Language);
            }
            else
            {
                datasource.Errors = Models.Utils.ParseErrors(ModelState.Values);
            }

            datasource.Data = (from p in models
                               join r in result on new { p.CompanyId, p.ObjectName } equals new { r.CompanyId, r.ObjectName }
                               select new PageDivViewModel
            {
                Id = r.Id,
                TableName = p.TableName,
                ObjectName = p.ObjectName,
                DivType = "Form",
                Title = p.Title,
                MenuId = p.MenuId,
                CompanyId = CompanyId
            }).ToList();
            var Id      = datasource.Data.Select(i => i.Id).ToList();
            var tblName = datasource.Data.Select(i => i.TableName).ToList();

            _hrUnitOfWork.PageEditorRepository.AddSectionColumns(Id);
            SaveChanges(Language);
            for (int i = 0; i < Id.Count(); i++)
            {
                _hrUnitOfWork.PageEditorRepository.AddFormColumns(Id[i], tblName[i]);
            }
            // _hrUnitOfWork.PageEditorRepository.AddFormColumns(Id,tblName);
            SaveChanges(Language);


            if (datasource.Errors.Count() > 0)
            {
                return(Json(datasource));
            }
            else
            {
                return(Json(datasource.Data));
            }
        }