Ejemplo n.º 1
0
        public List <ProductAttributeDTO> GetSelectList()
        {
            var result = new List <ProductAttributeDTO>();
            var roleId = MBHelper.GetUserRoleId(User);

            result = ProductAttributeService.GetAll().Where(x => !x.Deleted).ProjectTo <ProductAttributeDTO>().ToList();
            return(result);
        }
Ejemplo n.º 2
0
        public List <ManufacturerDTO> GetSelectList()
        {
            var result = new List <ManufacturerDTO>();
            var roleId = MBHelper.GetUserRoleId(User);

            result = ManufacturerService.GetAll().Where(x => !x.Deleted).ProjectTo <ManufacturerDTO>().ToList();
            return(result);
        }
Ejemplo n.º 3
0
        public List <StorageDTO> GetStorageSelectList()
        {
            var result      = new List <StorageDTO>();
            var roleId      = MBHelper.GetUserRoleId(User);
            var storageType = 0;

            if (roleId == (int)RoleType.Member)
            {
                storageType = (int)StorageType.Member;
            }
            result = StorageService.GetAll().Where(x => !x.Deleted && x.StorageType == storageType).ProjectTo <StorageDTO>().ToList();
            return(result);
        }
Ejemplo n.º 4
0
        public IList <PermissionItem> LoadPermission()
        {
            int userRoleId = MBHelper.GetUserRoleId(User);
            var role       = UserRoleService.GetAll()
                             .Include(x => x.UserPermissions)
                             .Single(x => x.Id == userRoleId && !x.Deleted);

            var result = role.UserPermissions.Select(x => new PermissionItem()
            {
                Id         = x.Id,
                Action     = x.Action,
                Controller = x.Controller
            }).ToList();

            return(result);
        }
Ejemplo n.º 5
0
        public async Task <IHttpActionResult> Create([FromBody] StorageDTO StorageDto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var entity = StorageDto.ToEntity();
            var roleId = MBHelper.GetUserRoleId(User);

            if (roleId == (int)RoleType.Member)
            {
                entity.StorageType = (int)StorageType.Member;
            }
            else
            {
                entity.StorageType = (int)StorageType.System;
            }
            entity.CreateUserId = User.Identity.GetUserId();
            entity.CreateTime   = DateTime.Now;
            await StorageService.InsertAsync(entity);

            return(Ok(entity.ToModel()));
        }