Esempio n. 1
0
        public OperationDetails EditAttributeGroup(AttributeGroupDTO dto)
        {
            AttributeGroup group = _unitOfWork.AttributeGroupRepsitory.Get(c => c.Id == dto.Id).FirstOrDefault();

            group.SortOrder    = dto.SortOrder;
            group.DateAdded    = DateTime.Now;
            group.DateModefied = DateTime.Now;
            _unitOfWork.AttributeGroupRepsitory.Update(group);

            long arabicLang  = (long)Langs.Arabic;
            long englishLang = (long)Langs.English;

            AttributeGroupDescription arabicDescription = _unitOfWork.AttributeGroupDescriptionRepsitory.Get(c => c.GroupId == dto.Id && c.LanguageId == arabicLang).FirstOrDefault();

            AttributeGroupDescription englishDescription = _unitOfWork.AttributeGroupDescriptionRepsitory.Get(c => c.GroupId == dto.Id && c.LanguageId == englishLang).FirstOrDefault();


            arabicDescription.Text         = dto.ArabicName;
            arabicDescription.LanguageId   = (long)Langs.Arabic;
            arabicDescription.DateModefied = DateTime.Now;


            englishDescription.Text         = dto.EnglishName;
            englishDescription.DateModefied = DateTime.Now;

            _unitOfWork.AttributeGroupDescriptionRepsitory.Update(arabicDescription);
            _unitOfWork.AttributeGroupDescriptionRepsitory.Update(englishDescription);

            _unitOfWork.Save();
            return(new OperationDetails(true, "تمت تعديل مجموعة الواصفات بنجاح", ""));
        }
Esempio n. 2
0
        public OperationDetails AddAttributeGroup(AttributeGroupDTO dto)
        {
            AttributeGroup group = new AttributeGroup();

            group.SortOrder    = dto.SortOrder;
            group.DateAdded    = DateTime.Now;
            group.DateModefied = DateTime.Now;
            group = _unitOfWork.AttributeGroupRepsitory.Insert(group);

            AttributeGroupDescription arabicDescription  = new AttributeGroupDescription();
            AttributeGroupDescription englishDescription = new AttributeGroupDescription();

            arabicDescription.GroupId      = group.Id;
            arabicDescription.Text         = dto.ArabicName;
            arabicDescription.LanguageId   = (long)Langs.Arabic;
            arabicDescription.DateAdded    = DateTime.Now;
            arabicDescription.DateModefied = DateTime.Now;

            englishDescription.GroupId      = group.Id;
            englishDescription.Text         = dto.EnglishName;
            englishDescription.LanguageId   = (long)Langs.English;
            englishDescription.DateAdded    = DateTime.Now;
            englishDescription.DateModefied = DateTime.Now;
            _unitOfWork.AttributeGroupDescriptionRepsitory.Insert(arabicDescription);
            _unitOfWork.AttributeGroupDescriptionRepsitory.Insert(englishDescription);

            _unitOfWork.Save();
            return(new OperationDetails(true, "تمت إضافة مجموعة الواصفات بنجاح", ""));
        }
Esempio n. 3
0
        public ActionResult Edit(long Id)
        {
            AttributeGroupDTO attributeGroupDTO = _ManageAttributeGroup.GetAttributeGroupById(Id);

            Mapper.Initialize(c => c.CreateMap <AttributeGroupDTO, AttributeGroupVM>());
            AttributeGroupVM attributeGroup = Mapper.Map <AttributeGroupDTO, AttributeGroupVM>(attributeGroupDTO);

            return(View(attributeGroup));
        }
Esempio n. 4
0
        public AttributeGroupDTO GetAttributeGroupById(long Id)
        {
            AttributeGroup group = _unitOfWork.AttributeGroupRepsitory.Get(c => c.Id == Id).FirstOrDefault();

            long arabicLang  = (long)Langs.Arabic;
            long englishLang = (long)Langs.English;

            AttributeGroupDTO groupDto = new AttributeGroupDTO();

            groupDto.Id          = group.Id;
            groupDto.ArabicName  = group.AttributeGroupDescriptions.Where(c => c.LanguageId == arabicLang).Select(n => n.Text).FirstOrDefault();
            groupDto.EnglishName = group.AttributeGroupDescriptions.Where(c => c.LanguageId == englishLang).Select(n => n.Text).FirstOrDefault();
            groupDto.SortOrder   = group.SortOrder;
            return(groupDto);
        }
Esempio n. 5
0
        public ActionResult Add(AttributeGroupVM group)
        {
            if (ModelState.IsValid)
            {
                Mapper.Initialize(c => c.CreateMap <AttributeGroupVM, AttributeGroupDTO>());
                AttributeGroupDTO dto = Mapper.Map <AttributeGroupVM, AttributeGroupDTO>(group);
                OperationDetails  op  = _ManageAttributeGroup.AddAttributeGroup(dto);

                return(Json(new { Succedeed = op.Succedeed, message = op.Message }));
            }
            else
            {
                return(View(group));
            }
        }
Esempio n. 6
0
        public List <AttributeGroupDTO> GetAllAttributeGroups(Langs l)
        {
            List <AttributeGroup>    groups     = _unitOfWork.AttributeGroupRepsitory.Get(c => true).ToList();
            List <AttributeGroupDTO> groupsDtos = new List <AttributeGroupDTO>();

            long lang = Utils.getLanguage(l);

            foreach (var group in groups)
            {
                AttributeGroupDTO dto = new AttributeGroupDTO();
                dto.Id         = group.Id;
                dto.Name       = group.AttributeGroupDescriptions.Where(c => c.LanguageId == lang).Select(g => g.Text).FirstOrDefault();
                dto.Attributes = GetAttributeGroupAttributes(group.Id, l);
                groupsDtos.Add(dto);
            }
            return(groupsDtos);
        }
Esempio n. 7
0
        public List <AttributeGroupDTO> GetAllAttributeGroups()
        {
            List <AttributeGroupDTO> groupsDTOs = new List <AttributeGroupDTO>();
            List <AttributeGroup>    groups     = _unitOfWork.AttributeGroupRepsitory.Get(c => true).ToList();

            foreach (var group in groups)
            {
                long arabic  = (long)Langs.Arabic;
                long english = (long)Langs.English;

                AttributeGroupDTO groupDTO = new AttributeGroupDTO();
                groupDTO.ArabicName  = group.AttributeGroupDescriptions.Where(c => c.LanguageId == arabic).Select(g => g.Text).FirstOrDefault();
                groupDTO.EnglishName = group.AttributeGroupDescriptions.Where(c => c.LanguageId == english).Select(g => g.Text).FirstOrDefault();
                groupDTO.SortOrder   = group.SortOrder;
                groupDTO.Id          = group.Id;
                groupsDTOs.Add(groupDTO);
            }
            return(groupsDTOs);
        }