Exemple #1
0
        public Sys_ResourceModel Put(Sys_ResourceModel model)
        {
            var Resource = new Sys_ResourceEntity
            {
                ID = model.ID,
                Code = model.Code,
                //ResourceType = model.ResourceType,
                ResourceName = model.ResourceName,
                ModuleName = model.ModuleName,
                //Description = model.Description
               
            };
            var service = new Sys_ResourceServices();
            if (model.ID != Guid.Empty)
            {
                Resource.ID = model.ID;
                service.Edit<Sys_ResourceEntity>(Resource);
            }
            else
            {
                service.Add<Sys_ResourceEntity>(Resource);
            }

            return model;
        }
Exemple #2
0
        // GET api/<controller>
        /// <summary>
        /// Lấy tất cả dữ liệu
        /// </summary>
        /// <returns></returns>
        public IEnumerable<Sys_ResourceModel> Get()
        {
            var service = new Sys_ResourceServices();
            var list = service.GetAllUseEntity<Sys_ResourceEntity>(ref status);

            return list.Select(item => new Sys_ResourceModel
            {
                ID = item.ID,
                Code = item.Code,
                //ResourceType = item.ResourceType,
                ResourceName = item.ResourceName,
                ModuleName = item.ModuleName,
                //Description = item.Description
            });
        }
Exemple #3
0
 // GET api/<controller>/5
 public Sys_ResourceModel Get(Guid id)
 {
     var service = new Sys_ResourceServices();
     var result = service.GetById<Sys_ResourceEntity>(id, ref status);
     var AttWorkDay = new Sys_ResourceModel
     {
         ID = result.ID,
         Code = result.Code,
         //ResourceType = result.ResourceType,
         ResourceName = result.ResourceName,
         ModuleName = result.ModuleName,
         //Description = result.Description
     };
     return AttWorkDay;
 }
Exemple #4
0
 // DELETE api/<controller>/5
 public void Delete(Guid id)
 {
     var service = new Sys_ResourceServices();
     var result = service.Remove<Sys_ResourceEntity>(id);
 }
        /// <summary> Lấy danh sách nhóm quyền theo GroupId </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public IEnumerable<Sys_GroupPermissionModel> Get(Guid id)
        {
            string statusGroupPermission = string.Empty;
            string status = string.Empty;
            var serviceGroupPermission = new Sys_GroupPermissionServices();
            var serviceResource = new Sys_ResourceServices();

            var listGroupPermission =
                serviceGroupPermission.GetData<Sys_GroupPermission2Entity>(id,
                    ConstantSql.hrm_sys_sp_get_GroupPermissionByGroupId, UserLogin, ref statusGroupPermission).Select(p => new Sys_GroupPermissionModel
            {
                ID = p.ID,
                GroupID = p.GroupID,
                ResourceID = p.ResourceID,
                GroupName = p.GroupName,
                ModuleName = p.ModuleName,
                ResourceName = p.ResourceName,
                ResourceType = p.ResourceType,
                Code = p.Code,
                Category = p.Category,
                PrivilegeNumber = Convert.ToInt32(p.PrivilegeNumber ?? 0)
            }).ToList();

            List<Guid> listResourceID = listGroupPermission.Select(d => d.ResourceID).Distinct().ToList();
            var resourceQueryable = serviceResource.GetAllResources();

            if (listResourceID.Count() >= 0 && resourceQueryable != null)
            {
                resourceQueryable = resourceQueryable.Where(d => !listResourceID.Contains(d.ID)).ToList();
            }

            if (listGroupPermission != null && resourceQueryable != null && resourceQueryable.Any())
            {
                listGroupPermission.AddRange(resourceQueryable.Select(d => new Sys_GroupPermissionModel
                {
                    GroupID = id,
                    ResourceID = d.ID,
                    ModuleName = d.ModuleName,
                    Category = d.Category,
                    ResourceType = d.ResourceType,
                    ResourceName = d.ResourceName
                }).ToList());
            }


            var lstGroupPermissionWithLMS = listGroupPermission.Where(p => p.Category == "LMS").ToList();
            var lstGroupPermissionWithoutLMS = listGroupPermission.Where(p => p.Category != "LMS").ToList();

            foreach (var sysResourceEntity in lstGroupPermissionWithLMS)
            {
                if (sysResourceEntity.Category == "LMS")
                {
                    sysResourceEntity.Category = HRM.Infrastructure.Utilities.ModuleName.Laundry.ToString();
                    sysResourceEntity.ModuleName = HRM.Infrastructure.Utilities.ModuleName.Laundry.ToString();
                }
            }

            lstGroupPermissionWithLMS.AddRange(lstGroupPermissionWithoutLMS);
            lstGroupPermissionWithLMS = lstGroupPermissionWithLMS.OrderBy(p => p.ResourceName).ToList();

            return lstGroupPermissionWithLMS ?? (lstGroupPermissionWithLMS = new List<Sys_GroupPermissionModel>());
            //   return listGroupPermission ?? (listGroupPermission = new List<Sys_GroupPermissionModel>());
        }