Exemplo n.º 1
0
        public ActionResult Index()
        {
            CustomerM          customer  = authService.DecodeJWT(User.Identity.Name);
            List <ShoppingDTO> shoppings = new List <ShoppingDTO>();

            foreach (var shopping in shoppingService.FindAll().Where(x => x.CustomerId == customer.Id && x.Status == "Active"))
            {
                shoppings.Add(new ShoppingDTO()
                {
                    MobileName = mobileService.FindById(shopping.MobileId).Name,
                    ShopName   = shopService.FindById(shopping.ShopId).ShopName,
                    Id         = shopping.Id,
                    Price      = shopping.Price,
                    ShopId     = shopping.ShopId,
                    MobileId   = shopping.MobileId,
                    CustomerId = shopping.CustomerId,
                });
            }

            return(View(shoppings));
        }
Exemplo n.º 2
0
        public ActionResult History()
        {
            CustomerM          admin     = authService.DecodeJWT(User.Identity.Name);
            ShopM              shop      = shopService.FindById(admin.ShopAdminId);
            List <ShoppingDTO> shoppings = new List <ShoppingDTO>();

            foreach (var shopping in shoppingService.FindAll().Where(x => x.ShopId == shop.Id))
            {
                shoppings.Add(new ShoppingDTO()
                {
                    Id         = shopping.Id,
                    Customer   = admin.Email,
                    CustomerId = admin.Id,
                    MobileId   = shopping.MobileId,
                    MobileName = mobileService.FindById(shopping.MobileId).Name,
                    Price      = shopping.Price,
                    Status     = shopping.Status,
                });
            }


            return(View(shoppings));
        }
Exemplo n.º 3
0
        public ActionResult Index(int?page)
        {
            string sort     = CheckParameter("sort");
            string search   = CheckParameter("Search");
            string max      = CheckParameter("Max");
            string min      = CheckParameter("Min");
            var    externs  = CheckAndConvertParameter("Externs");
            var    interns  = CheckAndConvertParameter("Interns");
            var    shops    = CheckAndConvertParameter("Shops");
            var    touches  = CheckAndConvertParameter("Touches");
            var    os       = CheckAndConvertParameter("OS");
            var    ram      = CheckAndConvertParameter("Ram");
            var    battery  = CheckAndConvertParameter("Battery");
            var    fronts   = CheckAndConvertParameter("Fronts");
            var    backs    = CheckAndConvertParameter("Backs");
            var    FMRadio  = CheckParameter("FMRadio");
            var    HDVoice  = CheckParameter("HDVoice");
            var    Port35mm = CheckParameter("Port35mm");

            double.TryParse(max, out double maxDouble);
            double.TryParse(min, out double minDouble);

            ViewBag.Search   = Request.QueryString["search"];
            ViewBag.Max      = Request.QueryString["max"];
            ViewBag.Min      = Request.QueryString["min"];
            ViewBag.Externs  = Request.QueryString["externs"];
            ViewBag.Interns  = Request.QueryString["interns"];
            ViewBag.Shops    = Request.QueryString["shops"];
            ViewBag.Touches  = Request.QueryString["touches"];
            ViewBag.OS       = Request.QueryString["os"];
            ViewBag.Ram      = Request.QueryString["ram"];
            ViewBag.Battery  = Request.QueryString["battery"];
            ViewBag.Fronts   = Request.QueryString["fronts"];
            ViewBag.Backs    = Request.QueryString["backs"];
            ViewBag.FMRadio  = Request.QueryString["fmradio"];
            ViewBag.HDVoice  = Request.QueryString["hdvoice"];
            ViewBag.Port35mm = Request.QueryString["port35mm"];
            ViewBag.Sort     = Request.QueryString["sort"];

            IEnumerable <ShopMobilesM> shopMobiles = shopMobilesService.FindAll().Where(x =>
                                                                                        x.MobilesLeft > 0 &&
                                                                                        (search != null ? mobileService.FindById(x.MobileId).Name.ToLower().Contains(search.ToLower()) : true) &&
                                                                                        (maxDouble != 0 ? x.Price <= maxDouble : true) &&
                                                                                        (minDouble != 0 ? x.Price >= minDouble : true) &&
                                                                                        (externs != null ? externs.Contains(mobileService.FindById(x.MobileId).ExternMemoryId.ToString()) : true) &&
                                                                                        (interns != null ? interns.Contains(mobileService.FindById(x.MobileId).InternMemoryId.ToString()) : true) &&
                                                                                        (shops != null ? shops.Contains(x.ShopId.ToString()) : true) &&
                                                                                        (touches != null ? (touches.Contains("yes") && mobileService.FindById(x.MobileId).Touch) || (touches.Contains("no") && !mobileService.FindById(x.MobileId).Touch) : true) &&
                                                                                        (os != null ? os.Contains(mobileService.FindById(x.MobileId).OsId.ToString()) : true) &&
                                                                                        (ram != null ? ram.Contains(mobileService.FindById(x.MobileId).RamId.ToString()) : true) &&
                                                                                        (battery != null ? battery.Contains(mobileService.FindById(x.MobileId).BatteryId.ToString()) : true) &&
                                                                                        (fronts != null ? fronts.Contains(mobileService.FindById(x.MobileId).FrontCameraId.ToString()) : true) &&
                                                                                        (backs != null ? backs.Contains(mobileService.FindById(x.MobileId).BackCameraId.ToString()) : true) &&
                                                                                        (FMRadio != null ? FMRadio.Contains("True") && mobileService.FindById(x.MobileId).FMRadio : true) &&
                                                                                        (HDVoice != null ? HDVoice.Contains("True") && mobileService.FindById(x.MobileId).HDVoice : true) &&
                                                                                        (Port35mm != null ? Port35mm.Contains("True") && mobileService.FindById(x.MobileId).Port35mm : true)
                                                                                        );

            if (sort == null || sort == "1")
            {
                shopMobiles = shopMobiles.OrderBy(x => x.Price);
            }
            else
            {
                shopMobiles = shopMobiles.OrderByDescending(x => x.Price);
            }
            List <HomeMobile> homeMobiles = new List <HomeMobile>();

            foreach (ShopMobilesM sm in shopMobiles)
            {
                List <string> images = new List <string>();
                foreach (ImagesM img in imageService.FindByMobile(sm.MobileId))
                {
                    images.Add(Convert.ToBase64String(img.ImageBinary));
                }

                homeMobiles.Add(new HomeMobile()
                {
                    Id       = sm.Id,
                    Name     = mobileService.FindById(sm.MobileId).Name,
                    Price    = sm.Price,
                    ShopId   = sm.ShopId,
                    ShopName = shopService.FindById(sm.ShopId).ShopName,
                    Images   = images,
                    MobileId = sm.MobileId,
                });
            }

            var minMax = shopMobilesService.FindAll().OrderBy(x => x.Price).ToList();

            DropDowns dropDowns = new DropDowns()
            {
                Batteries        = batteryService.FindAll(),
                Cameras          = cameraService.FindAll(),
                Memories         = memoryService.FindAll(),
                Shops            = shopService.FindAll(),
                OperativeSystems = operativeSystemService.FindAll(),
                Rams             = ramService.FindAll(),
                MaxPrice         = minMax.Count > 0 ? minMax[minMax.Count - 1].Price : 0,
                MinPrice         = minMax.Count > 0 ? minMax[0].Price : 0,
            };
            HomeDTO homeDTO = new HomeDTO()
            {
                Drops   = dropDowns,
                Mobiles = homeMobiles.ToPagedList(page ?? 1, 3),
            };

            return(View(homeDTO));
        }
Exemplo n.º 4
0
        public ActionResult One(int id)
        {
            ShopMobilesM shopMobiles = shopMobilesService.FindById(id);

            if (shopMobiles == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            List <string> images = new List <string>();

            foreach (ImagesM img in imageService.FindByMobile(shopMobiles.MobileId))
            {
                images.Add(Convert.ToBase64String(img.ImageBinary));
            }
            MobileM          mobile          = mobileService.FindById(shopMobiles.MobileId);
            CameraM          backCamera      = cameraService.FindById(mobile.BackCameraId);
            CameraM          frontCamera     = cameraService.FindById(mobile.FrontCameraId);
            RamM             ram             = ramService.FindById(mobile.RamId);
            MemoryM          internMemory    = memoryService.FindById(mobile.InternMemoryId);
            MemoryM          externMemory    = memoryService.FindById(mobile.ExternMemoryId);
            OperativeSystemM operatingSystem = operativeSystemService.FindById(mobile.OsId);
            BatteryM         battery         = batteryService.FindById(mobile.BatteryId);

            return(View(new OneMobile()
            {
                Shop = shopService.FindById(shopMobiles.ShopId),
                Images = images,
                Price = shopMobiles.Price,
                About = mobile.About,
                AdditionalDescription = mobile.AdditionalDescription,
                BackCamera = backCamera != null ? backCamera.MP : "",
                FrontCamera = frontCamera != null ? frontCamera.MP : "",
                BackCameraChar = mobile.BackCameraChar,
                BatteryCapacity = battery != null ? battery.Capacity : "",
                Bluetooth = mobile.Bluetooth,
                DataTransfer = mobile.DataTransfer,
                Dimensions = mobile.Dimensions,
                DualSIM = mobile.DualSIM,
                ExternMemory = externMemory != null ? externMemory.Size : "",
                FMRadio = mobile.FMRadio,
                FrontCameraChar = mobile.FrontCameraChar,
                GPS = mobile.GPS,
                HDVoice = mobile.HDVoice,
                Id = mobile.Id,
                InternMemory = internMemory != null ? internMemory.Size : "",
                Name = mobile.Name,
                Network2G = mobile.Network2G,
                Network3G = mobile.Network3G,
                Network4G = mobile.Network4G,
                NFC = mobile.NFC,
                OperatingSystem = operatingSystem != null ? operatingSystem.OS : "",
                PackageContent = mobile.PackageContent,
                PhoneMessages = mobile.PhoneMessages,
                PhoneWeight = mobile.PhoneWeight,
                Port35mm = mobile.Port35mm,
                Proccessor = mobile.Proccessor,
                RAM = ram != null ? ram.Memory : "",
                Resolution = mobile.Resolution,
                ScreenSize = mobile.ScreenSize,
                ScreenType = mobile.ScreenType,
                SIM = mobile.SIM,
                Touch = mobile.Touch,
                USB = mobile.USB,
                Video = mobile.Video,
                WiFi = mobile.WiFi,
            }));
        }