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); }
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); }
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); }
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); }
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())); }
public async Task <IHttpActionResult> List( int categoryId = 0, int manufacturerId = 0, int carId = 0, string keywords = null, string specs = null, int pageIndex = 0, int pageSize = 0, string location = null, bool isAgreeActive = false, bool album = false, int?orderBy = null, decimal?minPrice = null, decimal?maxPrice = null ) { var result = new ApiResult <CategoryModel>(); var model = new CategoryModel(); var categoryIds = new List <int>(); var manufacturerIds = new List <int>(); if (manufacturerId != 0) { manufacturerIds.Add(manufacturerId); } DbGeography Location = null; if (!string.IsNullOrEmpty(location)) { Location = DbGeography.FromText(string.Format("POINT({0})", location)); } if (categoryId != 0) { Category entity = await CategoryService.FindOneAsync(categoryId); model = new CategoryModel() { Id = entity.Id, Description = entity.Description, Name = entity.Name, ImageUrl = entity.ImageUrl }; model.SubCategories = CategoryService.GetAll() .Where(x => !x.Deleted && x.ParentId.Value == entity.Id) .ProjectTo <CategoryDTO>().OrderBy(x => x.DisplayOrder).ToList(); categoryIds.Add(entity.Id); categoryIds.AddRange(model.SubCategories.Select(x => x.Id)); } if (pageSize == 0) { pageSize = 20; } int RoleId = 2; IList <int> alreadyFilteredSpecOptionIds = MBHelper.StringToIds(specs); IList <int> filterableSpecificationAttributeOptionIds; var loadFilterableSpecificationAttributeOptionIds = pageIndex == 0; var products = ProductService.SearchProducts( out filterableSpecificationAttributeOptionIds, categoryIds: categoryIds, manufacturerIds: manufacturerIds, carId: carId, loadFilterableSpecificationAttributeOptionIds: loadFilterableSpecificationAttributeOptionIds, showHidden: true, location: Location, featuredProducts: null, keywords: keywords, //RoleId: MBHelper.GetUserRoleId(User), RoleId: RoleId, priceMin: minPrice, priceMax: maxPrice, filteredSpecs: alreadyFilteredSpecOptionIds, isAgreeActive: isAgreeActive, album: album, //orderBy: (ProductSortingEnum)command.OrderBy, orderBy: orderBy.HasValue ? (ProductSortingEnum)orderBy : ProductSortingEnum.Position, pageIndex: pageIndex, pageSize: pageSize); //model.Products = PrepareProductOverviewModels(products).ToList(); model.Products = products.Select(x => new ProductOverviewModel() { Description = x.Description, Id = x.Id, ImageUrl = x.ImageUrl, Name = x.Name, Price = x.Price, VipPrice = x.VipPrice, Distance = x.Distance }).ToList(); model.TotalCount = products.TotalCount; if (loadFilterableSpecificationAttributeOptionIds) { model.PrepareSpecsFilters(alreadyFilteredSpecOptionIds, filterableSpecificationAttributeOptionIds != null ? filterableSpecificationAttributeOptionIds.ToArray() : null, SpecificationAttributeOptionService, CacheManager); } result.Data = model; return(Ok(result)); }