public ActionResult PurposesList(Guid id, string st, IList <FilterVM> filterVMs)
        {
            var charValueDTOList = new List <CharValueDTO>();

            foreach (var i in filterVMs)
            {
                foreach (var j in i.ValuesList)
                {
                    if (j.isApplied)
                    {
                        var buff = new CharValueDTO();
                        buff.Id = j.Id;
                        buff.CharacteristicId = j.CharacteristicId;
                        buff.IntVal           = j.IntVal;
                        buff.FloatVal         = j.FloatVal;
                        buff.StrVal           = j.StrVal;
                        charValueDTOList.Add(buff);
                    }
                }
            }
            var purposes = _catalog.GetPurposesByCharValues((Guid)id, charValueDTOList);

            var purposeList = new List <CatalogPurposeVM>();

            foreach (var curr in purposes)
            {
                CatalogPurposeVM buff = new CatalogPurposeVM();
                buff.PurposeID  = curr.PurposeID;
                buff.CategoryID = id;
                buff.Brand      = curr.Brand;
                buff.Name       = curr.Name;
                buff.Price      = curr.Price;
                buff.Curency    = curr.Curency;
                buff.Category   = curr.CategoryName;

                purposeList.Add(buff);
                buff = null;
            }
            if (String.IsNullOrEmpty(st))
            {
                st = "ByPrice";
            }

            switch (st)
            {
            case "ByName":
                purposeList = purposeList.OrderBy(x => x.Name).Distinct().ToList();
                break;

            case "ByPrice":
                purposeList = purposeList.OrderBy(x => x.Price).ToList();
                break;

            case "ByBrand":
                purposeList = purposeList.OrderBy(x => x.Brand).ToList();
                break;
            }

            return(View(purposeList));
        }
Exemple #2
0
        public async Task OnGetAsync()
        {
            var allMedia = await mpc.GetMediaAsync();

            foreach (var item in allMedia)
            {
                MediaDTO media = new MediaDTO();
                media.Id              = item.Id;
                media.Type            = item.Type;
                media.AbsPath         = item.AbsPath;
                media.Deleted         = item.Deleted;
                media.Characteristics = new List <CharacteristicDTO>();

                foreach (var cc in item.Characteristics)
                {
                    CharacteristicDTO cdto = new CharacteristicDTO();
                    cdto.Id         = cc.Id;
                    cdto.Name       = cc.Name;
                    cdto.Type       = cc.Type;
                    cdto.CharValues = new List <CharValueDTO>();

                    foreach (var cv in cc.CharValues)
                    {
                        CharValueDTO cvdto = new CharValueDTO();
                        cvdto.Id    = cv.Id;
                        cvdto.Value = cv.Value;
                        cdto.CharValues.Add(cvdto);
                    }

                    media.Characteristics.Add(cdto);
                }

                Media.Add(media);
            }
        }
        public void CreateCharacteristicValue(CharValueDTO dto)
        {
            var newCharValue = new CharValue();

            newCharValue.CharacteristicId = dto.CharacteristicId;
            newCharValue.Id       = Guid.NewGuid();
            newCharValue.IntVal   = dto.IntVal;
            newCharValue.FloatVal = dto.FloatVal;
            newCharValue.StrVal   = dto.StrVal;
            _characteristicValueRepository.Create(newCharValue);
        }
        public ActionResult CreateCharacteristicValue(CharValueVM newCharValue)
        {
            var dto = new CharValueDTO();

            dto.CharacteristicId = newCharValue.CharacteristicId;
            dto.IntVal           = newCharValue.IntVal;
            dto.StrVal           = newCharValue.StrVal;
            dto.FloatVal         = newCharValue.FloatVal;
            _catalog.CreateCharacteristicValue(dto);
            return(RedirectToAction("GetCharacteristicsValues", "ContentManagerAccount", new { CharacteristicId = newCharValue.CharacteristicId }));
        }
        public CharValueDTO GetCharacteristicValueByID(Guid id)
        {
            var curr = _characteristicValueRepository.FindById(id);
            var dto  = new CharValueDTO();

            dto.Id = curr.Id;
            dto.CharacteristicId = curr.CharacteristicId;
            dto.IntVal           = curr.IntVal;
            dto.FloatVal         = curr.FloatVal;
            dto.StrVal           = curr.StrVal;
            return(dto);
        }
Exemple #6
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var allMedia = await mpc.GetMediaAsync();

            foreach (var item in allMedia)
            {
                if (item.Id == id)
                {
                    Media.Id              = item.Id;
                    Media.Type            = item.Type;
                    Media.AbsPath         = item.AbsPath;
                    Media.Deleted         = item.Deleted;
                    Media.Characteristics = new List <CharacteristicDTO>();

                    foreach (var cc in item.Characteristics)
                    {
                        CharacteristicDTO cdto = new CharacteristicDTO();
                        cdto.Id         = cc.Id;
                        cdto.Name       = cc.Name;
                        cdto.Type       = cc.Type;
                        cdto.CharValues = new List <CharValueDTO>();

                        foreach (var cv in cc.CharValues)
                        {
                            if (cv.Media.Id == id)
                            {
                                CharValueDTO cvdto = new CharValueDTO();
                                cvdto.Id    = cv.Id;
                                cvdto.Value = cv.Value;
                                cdto.CharValues.Add(cvdto);
                            }
                        }

                        Media.Characteristics.Add(cdto);
                    }
                }
            }

            if (Media == null)
            {
                return(NotFound());
            }
            return(Page());
        }
        public IEnumerable <CharValueDTO> GetCharValuesByCharacteristicId(Guid characteristicId)
        {
            var charValues       = _characteristicValueRepository.Get(x => x.CharacteristicId == characteristicId);
            var charValueDTOList = new List <CharValueDTO>();

            foreach (var i in charValues)
            {
                var charValueDTO = new CharValueDTO();
                charValueDTO.Id = i.Id;
                charValueDTO.CharacteristicId = i.CharacteristicId;
                charValueDTO.IntVal           = i.IntVal;
                charValueDTO.FloatVal         = i.FloatVal;
                charValueDTO.StrVal           = i.StrVal;
                charValueDTOList.Add(charValueDTO);
            }
            return(charValueDTOList);
        }