Exemple #1
0
        public async Task <IActionResult> ShowAll()
        {
            List <Feedback> listFeedback;
            List <Thanks>   thanks;
            List <Gift>     gifts;
            List <Image>    images;

            await HttpContext.Session.LoadAsync();

            string brandId = HttpContext.Session.GetString("brandId");
            string listJson;
            IEnumerable <Feedback> list = await feedback.GetFeedbackByBrandId(brandId);

            if (list == null)
            {
                listFeedback = new List <Feedback>();
            }
            else
            {
                listFeedback = list.ToList();
            }
            listJson = CreateListJson <Feedback>(list);

            IEnumerable <Thanks> thanksEnum = await thanksRepository.GetThanksByBrandId(brandId);

            if (thanksEnum == null)
            {
                thanks = new List <Thanks>();
            }
            else
            {
                thanks = thanksEnum.ToList();
            }

            IEnumerable <Gift> giftsEnum = await giftRepository.GetGiftByBrandId(brandId);

            if (giftsEnum == null)
            {
                gifts = new List <Gift>();
            }
            else
            {
                gifts = giftsEnum.ToList();
            }

            IEnumerable <Image> imagesEnum = await imageRepository.GetImageByBrandId(brandId);

            if (imagesEnum == null)
            {
                images = new List <Image>();
            }
            else
            {
                images = imagesEnum.ToList();
            }
            await HttpContext.Session.CommitAsync();

            IEnumerable <EquipmentGroup> equipGroup = equipmentGroup.GetEquipmentGroup(brandId);
            List <EquipmentGroup>        listGroup  = new List <EquipmentGroup>();
            List <Equipment>             listEquip  = new List <Equipment>();

            if (equipGroup != null)
            {
                listGroup = equipGroup.ToList();
                foreach (EquipmentGroup group in listGroup)
                {
                    IQueryable <Equipment> tmp = equipment.GetEquipmentByGroupId(group.EquipmentGroupId);
                    if (tmp != null)
                    {
                        listEquip.AddRange(tmp.ToList());
                    }
                }
            }

            ViewBag.listFeedback = listFeedback;
            ViewBag.listEquip    = listEquip;
            ViewBag.listGroup    = listGroup;
            ViewBag.listThanks   = thanks;
            ViewBag.listGift     = gifts;
            ViewBag.listImage    = JsonConvert.SerializeObject(images);
            ViewBag.listJson     = listJson;

            ViewBag.email = HttpContext.Session.GetString("email");
            return(View());
        }