Esempio n. 1
0
        public async Task <IActionResult> Update(ProductAttributeModel model)
        {
            var productAttribute = new ProductAttributeModifyRequest()
            {
                Description = model.Description,
                Name        = model.Name,
                Id          = model.Id,
                UpdatedById = LoggedUserId
            };

            if (productAttribute.Id <= 0)
            {
                return(RedirectToErrorPage());
            }

            var exist = _productAttributeService.FindAsync(new IdRequestFilter <int>
            {
                Id = model.Id,
                CanGetInactived = true
            });

            if (exist == null)
            {
                return(RedirectToErrorPage());
            }

            await _productAttributeService.UpdateAsync(productAttribute);

            return(RedirectToAction(nameof(Detail), new { id = productAttribute.Id }));
        }
        public async Task <bool> ActiveAsync(ProductAttributeModifyRequest request)
        {
            await _productAttributeRepository.Get(x => x.Id == request.Id)
            .Set(x => x.StatusId, (int)ArticleCategoryStatus.Actived)
            .Set(x => x.UpdatedById, request.UpdatedById)
            .Set(x => x.UpdatedDate, DateTimeOffset.UtcNow)
            .UpdateAsync();

            return(true);
        }
        public async Task <bool> UpdateAsync(ProductAttributeModifyRequest category)
        {
            await _productAttributeRepository.Get(x => x.Id == category.Id)
            .Set(x => x.Description, category.Description)
            .Set(x => x.UpdatedById, category.UpdatedById)
            .Set(x => x.Name, category.Name)
            .UpdateAsync();

            return(true);
        }
        public async Task <int> CreateAsync(ProductAttributeModifyRequest productAttribute)
        {
            var newProductAttribute = new ProductAttribute
            {
                Description = productAttribute.Description,
                Name        = productAttribute.Name,
                StatusId    = ProductAttributeStatus.Actived.GetCode(),
                CreatedById = productAttribute.CreatedById,
                UpdatedById = productAttribute.UpdatedById,
                UpdatedDate = DateTime.UtcNow,
                CreatedDate = DateTime.UtcNow,
            };

            var id = await _productAttributeRepository.AddWithInt32EntityAsync(newProductAttribute);

            return(id);
        }
Esempio n. 5
0
        public async Task <IActionResult> Create(ProductAttributeModel model)
        {
            var productAttribute = new ProductAttributeModifyRequest()
            {
                Description = model.Description,
                Name        = model.Name,
                CreatedById = LoggedUserId,
                UpdatedById = LoggedUserId
            };

            var exist = await _productAttributeService.FindByNameAsync(model.Name);

            if (exist != null)
            {
                return(RedirectToErrorPage());
            }

            var id = await _productAttributeService.CreateAsync(productAttribute);

            return(RedirectToAction(nameof(Detail), new { id }));
        }
 public async Task <bool> DeactivateAsync(ProductAttributeModifyRequest request)
 {
     return(await _productAttributeRepository.DeactivateAsync(request));
 }
 public async Task <int> CreateAsync(ProductAttributeModifyRequest request)
 {
     return(await _productAttributeRepository.CreateAsync(request));
 }