public void NUnit_DataPermission_Domain_Add()
        {
            Sys_DataPermissionServices service = new Sys_DataPermissionServices();
            bool result  = true;
            int  countSC = 0;

            for (int i = 1; i <= 10; i++)
            {
                var model = new Sys_DataPermission
                {
                    Id      = i,
                    Code    = i.ToString(),
                    GroupID = 1,
                    UserID  = 1
                };
                var result1 = service.Add <Sys_DataPermission>(model);
                NUnit.Framework.Assert.IsTrue(result);
                if (result == true)
                {
                    countSC += 1;
                    Console.WriteLine("Process Success >>> Create >>> " + model.Id
                                      + " | " + model.Code
                                      );
                }
            }
            Console.WriteLine("Total success record: " + countSC);
        }
        public void NUnit_DataPermission_Domain_Add()
        {
            Sys_DataPermissionServices service = new Sys_DataPermissionServices();
            bool result = true;
            int countSC = 0;
            for (int i = 1; i <= 10; i++)
            {

                var model = new Sys_DataPermission
                {
                    Id = i,
                    Code = i.ToString(),
                    GroupID = 1,
                    UserID = 1
                };
             var   result1 = service.Add<Sys_DataPermission>(model);
                NUnit.Framework.Assert.IsTrue(result);
                if (result == true)
                {
                    countSC += 1;
                    Console.WriteLine("Process Success >>> Create >>> " + model.Id
                        + " | " + model.Code
                        );
                }
            }
            Console.WriteLine("Total success record: " + countSC);
        }
예제 #3
0
        public Sys_DataPermissionModel Post([FromBody] Sys_DataPermissionModel model)
        {
            var service = new Sys_DataPermissionServices();

            var dataPermissionExist = service.CheckDuplicateDataPermission(model.UserID, model.GroupID);

            if (dataPermissionExist.ID != Guid.Empty)
            {
                model.ID = dataPermissionExist.ID;
            }

            byte[] branches = null;
            if (model.Branches != null)
            {
                branches = model.Branches.ToBinary();
            }

            var entity = new Sys_DataPermissionEntity
            {
                ID           = model.ID,
                Code         = model.Code,
                Branches     = branches,
                GroupID      = model.GroupID,
                UserID       = model.UserID,
                DataGroup    = model.DataGroup,
                DataGroups   = model.DataGroups,
                OrgStructure = model.OrgStructure,
                WorkPlace    = model.WorkPlace
            };

            if (model.ID != Guid.Empty)
            {
                model.ID = model.ID;
                service.Edit <Sys_DataPermissionEntity>(entity);
            }
            else
            {
                service.Add <Sys_DataPermissionEntity>(entity);
                model.ID = entity.ID;
            }

            return(model);
        }