Esempio n. 1
0
        /*Save Or Update Attribute */
        public AttributeModel AddEditAttribute(AttributeModel attributeModel)
        {
            var attribute = new NAGGLE.DAL.Entities.Attribute();
            var attributeCategory= new List<AttributeCategory>();
            Mapper.Map(attributeModel, attribute);
            Mapper.Map(attributeModel.AttributeCategoryModel, attribute.AttributeCategory);

            var categoryInfo = _unitOfWork.attributeCategoryRespository.Get(m => m.AttributeId == attributeModel.AttributeId);

            if (attributeModel.AttributeId > 0)
            {
                attribute.UpdatedBy = GetLoginUserId();
                var deleteAttributecategory = categoryInfo.Where(m => !attribute.AttributeCategory.Any(y => y.CategoryId == m.CategoryId)).ToList();
                attributeCategory = attribute.AttributeCategory.Where(m => !categoryInfo.Any(y => y.CategoryId == m.CategoryId)).ToList();
                if (deleteAttributecategory.Count > 0)
                    _unitOfWork.attributeCategoryRespository.DeleteAll(deleteAttributecategory);
                if (attributeCategory.Count > 0)
                    _unitOfWork.attributeCategoryRespository.InsertAll(attributeCategory);

                //if (categoryInfo.Count > 0)
                //    _unitOfWork.attributeCategoryRespository.DeleteAll(categoryInfo);
                //categoryInfo = attribute.AttributeCategory.ToList();
                //_unitOfWork.attributeCategoryRespository.InsertAll(categoryInfo);
                _unitOfWork.attributeRespository.Update(attribute);

            }
            else
            {
                attribute.CreatedBy = GetLoginUserId();
                _unitOfWork.attributeRespository.Insert(attribute);
                // _unitOfWork.attributeCategoryRespository.InsertAll(categoryInfo);
            }
            _unitOfWork.Save();
            Mapper.Map(attribute, attributeModel);
            Mapper.Map(attribute.AttributeCategory, attributeModel.AttributeCategoryModel);
            return attributeModel;
        }
Esempio n. 2
0
        public AttributeModel UpdateAttributeStatus(AttributeModel attributeModel)
        {
            var attribute = new NAGGLE.DAL.Entities.Attribute();
            Mapper.Map(attributeModel, attribute);
            _unitOfWork.attributeRespository.Update(attribute);
            _unitOfWork.Save();
            Mapper.Map(attribute, attributeModel);

            return attributeModel;
        }
Esempio n. 3
0
        /*Get Specific Attribute Detail By id*/
        public AttributeModel GetAttributeById(int attributeId)
        {
            var attributeModel = new AttributeModel();

            var attribute = _unitOfWork.attributeRespository.Get(m => m.AttributeId == attributeId).FirstOrDefault();

            Mapper.Map(attribute, attributeModel);

            Mapper.Map(attribute.AttributeCategory, attributeModel.AttributeCategoryModel);

            return attributeModel;
        }
Esempio n. 4
0
        public List<AttributeModel> GetAttributeByCategoryId(List<int> categoryIds)
        {
            var attributeModelList = new List<AttributeModel>();

            var attributeCategory= _unitOfWork.attributeCategoryRespository.Get(m => categoryIds.Contains(m.CategoryId)).ToList();

            var attrId = new List<int>();
            for (int i = 0; i < attributeCategory.Count; i++)
            {
                var attributeModel = new AttributeModel();
                var isSameAttribute=attrId.Contains(attributeCategory[i].Attribute.AttributeId);//Distinct AttributeId
                if (!isSameAttribute)
                {
                    attrId.Add(attributeCategory[i].Attribute.AttributeId);

                    Mapper.Map(attributeCategory[i].Attribute, attributeModel);
                    attributeModelList.Add(attributeModel);
                }
            }
            //attributeModelList.DistinctBY
               // Mapper.Map(attribute.AttributeCategory, attributeModel.AttributeCategoryModel);

            return attributeModelList;
        }
Esempio n. 5
0
        public JsonResult AddEditAttribute(AttributeViewModel attributeViewModel)
        {
            var message = attributeViewModel.AttributeId != null ? "Updated" : "Saved";

            var attributeModel = new AttributeModel();
            Mapper.Map(attributeViewModel, attributeModel);
            Mapper.Map(attributeViewModel.AttributeCategories, attributeModel.AttributeCategoryModel);

            var attribute = _productService.AddEditAttribute(attributeModel);

            Mapper.Map(attribute, attributeViewModel);
            Mapper.Map(attribute.AttributeCategoryModel, attributeViewModel.AttributeCategories);

            return Json(new { Attribute = attributeViewModel, Success = true, Message = message }, JsonRequestBehavior.AllowGet);
        }
Esempio n. 6
0
        public JsonResult UpdateAttributeStatus(AttributeViewModel attributeViewModel)
        {
            var attributeModel = new AttributeModel();

            Mapper.Map(attributeViewModel, attributeModel);
            var att = _productService.UpdateAttributeStatus(attributeModel);
            Mapper.Map(att, attributeViewModel);

            return Json(attributeViewModel, JsonRequestBehavior.AllowGet);
        }