public void AddCategoryProperty(CategoryPropertyViewModel property)
        {
            var newCategory = new CategoryProperty()
            {
                CategoryId = property.CategoryId,
                PropertyId = property.PropertyId
            };

            _propertyRepository.AddProperty(newCategory);
        }
Beispiel #2
0
        public ActionResult Create(CategoryPropertyViewModel property)
        {
            try
            {
                _categoryService.AddCategoryProperty(property);

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #3
0
        public async Task <IActionResult> ListProperty(int CategoryId, CancellationToken cancellationToken)
        {
            try
            {
                List <ProppertyCategoryListDto> list = await _CategoryPropertyService.TableNoTracking.Where(e => e.CategoryId == CategoryId &&
                                                                                                            !e.IsDeleted)
                                                       /*.Include(e => e.ProductProperty)*/.ProjectTo <ProppertyCategoryListDto>(_mapper.ConfigurationProvider)
                                                       .OrderBy(e => e.TitleValue).ToListAsync(cancellationToken);

                var model = new CategoryPropertyViewModel
                {
                    ProppertyCategoryList = list,
                    CategoryId            = CategoryId
                };
                return(PartialView("_CreateProperty", model));
            }

            catch (Exception ex)
            {
                return(new JsonResult(new { items = false, message = OperationMessage.OperationFailed.ToDisplay() }));
            }
        }
Beispiel #4
0
        public async Task <IActionResult> AddProperty(CategoryPropertyViewModel ModelDto, int CategoryId, CancellationToken cancellationToken)
        {
            try
            {
                if (String.IsNullOrEmpty(ModelDto.TitleValue.Trim()))
                {
                    return(new JsonResult(new { confirm = false, message = OperationMessage.ModelStateIsNotValid.ToDisplay() }));
                }
                var ListProvince = _CategoryPropertyService.TableNoTracking.Where(e => e.TitleValue == ModelDto.TitleValue).ToList();
                if (ListProvince.Any(e => e.TitleValue.Equals(ModelDto.TitleValue.Trim(), StringComparison.OrdinalIgnoreCase)))
                {
                    return(new JsonResult(new { confirm = false, message = OperationMessage.DoestExist.ToDisplay() }));
                }
                var property = new CreatePropertyCategoryDto
                {
                    CategoryId = CategoryId,
                    TitleValue = ModelDto.TitleValue,
                    Type       = EnumExtensions.ParseEnum <TypeOfInputValue>(ModelDto.Type).ToString()
                };
                var model = property.ToEntity(_mapper);
                await _CategoryPropertyService.AddAsync(model, cancellationToken);

                string name = "'" + model.TitleValue + "'";
                string Url  = "'Category/DeleteProperty'";
                return(new JsonResult(new
                {
                    confirm = true,
                    message = OperationMessage.OperationSucceed.ToDisplay(),
                    Name = name,
                    Url = Url,
                    Id = model.Id
                }));
            }
            catch (Exception ex)
            {
                return(new JsonResult(new { confirm = false, message = OperationMessage.OperationFailed.ToDisplay() }));
            }
        }