Пример #1
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);
        }
Пример #2
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);
        }
Пример #3
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;
        }
Пример #4
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;
        }