Пример #1
0
        public MobileM Edit(MobileM mobile)
        {
            var found = Context.Mobiles.SingleOrDefault(x => x.Id == mobile.Id);

            if (found == null)
            {
                return(null);
            }
            found.About                 = mobile.About;
            found.MobileName            = mobile.Name;
            found.BatteryId             = mobile.BatteryId;
            found.BackCameraId          = mobile.BackCameraId;
            found.ExternMemoryId        = mobile.ExternMemoryId;
            found.InternMemoryId        = mobile.InternMemoryId;
            found.FrontCameraId         = mobile.FrontCameraId;
            found.OsId                  = mobile.OsId;
            found.Proccessor            = mobile.Proccessor;
            found.RamId                 = mobile.RamId;
            found.AdditionalDescription = mobile.AdditionalDescription;
            found.BackCameraChar        = mobile.BackCameraChar;
            found.Bluetooth             = mobile.Bluetooth;
            found.DataTransfer          = mobile.DataTransfer;
            found.Dimensions            = mobile.Dimensions;
            found.DualSIM               = mobile.DualSIM;
            found.FMRadio               = mobile.FMRadio;
            found.FrontCameraChar       = mobile.FrontCameraChar;
            found.GPS            = mobile.GPS;
            found.HDVoice        = mobile.HDVoice;
            found.Network2G      = mobile.Network2G;
            found.Network3G      = mobile.Network3G;
            found.Network4G      = mobile.Network4G;
            found.NFC            = mobile.NFC;
            found.PackageContent = mobile.PackageContent;
            found.PhoneMessages  = mobile.PhoneMessages;
            found.PhoneWeight    = mobile.PhoneWeight;
            found.Port35mm       = mobile.Port35mm;
            found.Resolution     = mobile.Resolution;
            found.Size           = mobile.ScreenSize;
            found.ScreenType     = mobile.ScreenType;
            found.SIM            = mobile.SIM;
            found.Touch          = mobile.Touch;
            found.USB            = mobile.USB;
            found.Video          = mobile.Video;
            found.WiFi           = mobile.WiFi;
            Context.SaveChanges();

            return(mobile);
        }
Пример #2
0
        public MobileM Save(MobileM mobile)
        {
            Mobile mobileDb = new Mobile()
            {
                MobileName            = mobile.Name,
                About                 = mobile.About,
                BatteryId             = mobile.BatteryId,
                BackCameraId          = mobile.BackCameraId,
                ExternMemoryId        = mobile.ExternMemoryId,
                InternMemoryId        = mobile.InternMemoryId,
                FrontCameraId         = mobile.FrontCameraId,
                OsId                  = mobile.OsId,
                Proccessor            = mobile.Proccessor,
                RamId                 = mobile.RamId,
                AdditionalDescription = mobile.AdditionalDescription,
                BackCameraChar        = mobile.BackCameraChar,
                Bluetooth             = mobile.Bluetooth,
                DataTransfer          = mobile.DataTransfer,
                Dimensions            = mobile.Dimensions,
                DualSIM               = mobile.DualSIM,
                FMRadio               = mobile.FMRadio,
                FrontCameraChar       = mobile.FrontCameraChar,
                GPS            = mobile.GPS,
                HDVoice        = mobile.HDVoice,
                Network2G      = mobile.Network2G,
                Network3G      = mobile.Network3G,
                Network4G      = mobile.Network4G,
                NFC            = mobile.NFC,
                PackageContent = mobile.PackageContent,
                PhoneMessages  = mobile.PhoneMessages,
                PhoneWeight    = mobile.PhoneWeight,
                Port35mm       = mobile.Port35mm,
                Resolution     = mobile.Resolution,
                Size           = mobile.ScreenSize,
                ScreenType     = mobile.ScreenType,
                SIM            = mobile.SIM,
                Touch          = mobile.Touch,
                USB            = mobile.USB,
                Video          = mobile.Video,
                WiFi           = mobile.WiFi,
            };

            Context.Mobiles.Add(mobileDb);
            Context.SaveChanges();
            mobile.Id = mobileDb.Id;
            return(mobile);
        }
Пример #3
0
        public ActionResult Add(ShoppingM shopping)
        {
            MobileM      mobile      = mobileService.FindById(shopping.MobileId);
            ShopM        shop        = shopService.FindById(shopping.ShopId);
            CustomerM    customer    = authService.DecodeJWT(User.Identity.Name);
            ShopMobilesM shopMobiles = shopMobilesService.FindByShopAndMobile(shop.Id, mobile.Id);

            if (!ModelState.IsValid || mobile == null || shop == null ||
                customer == null || shopMobiles == null || shopping.Price != shopMobiles.Price)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            shopping.CustomerId = customer.Id;
            shopping.Status     = "Active";
            shoppingService.Save(shopping);

            return(new HttpStatusCodeResult(HttpStatusCode.OK));
        }
Пример #4
0
        public ActionResult Manage()
        {
            CustomerM admin = authService.DecodeJWT(User.Identity.Name);
            IEnumerable <ShopMobilesM> shopMobiles = shopMobilesService.FindAll().Where(x => x.ShopId == admin.ShopAdminId);

            List <MobileDTO> mobileDTOs = new List <MobileDTO>();

            foreach (var m in shopMobiles)
            {
                MobileM mobile = mobileService.FindById(m.MobileId);
                mobileDTOs.Add(new MobileDTO()
                {
                    Id = m.MobileId, Amount = m.MobilesLeft, Price = m.Price, Name = mobile.Name
                });
            }

            return(View(mobileDTOs));
        }
Пример #5
0
        public ActionResult Create(NewMobileDTO mobileDTO)
        {
            MobileM          mobile                 = mobileDTO.Mobile;
            RamM             ram                    = ramService.FindById(mobile.RamId);
            MemoryM          internMemory           = memoryService.FindById(mobile.InternMemoryId);
            MemoryM          externMemory           = memoryService.FindById(mobile.ExternMemoryId);
            CameraM          backCamera             = cameraService.FindById(mobile.BackCameraId);
            CameraM          frontCamera            = cameraService.FindById(mobile.FrontCameraId);
            OperativeSystemM os                     = operativeSystemService.FindById(mobile.OsId);
            BatteryM         battery                = batteryService.FindById(mobile.BatteryId);
            IEnumerable <HttpPostedFileBase> Images = mobileDTO.Images;

            if (Images == null)
            {
                return(RedirectToAction("/New"));
            }

            if (ModelState.IsValid && ram != null && internMemory != null && externMemory != null &&
                backCamera != null && frontCamera != null && os != null && battery != null)
            {
                MobileM tempMobile = mobileService.Save(mobile);


                foreach (var image in Images)
                {
                    MemoryStream target = new MemoryStream();
                    image.InputStream.CopyTo(target);
                    imageService.Save(new ImagesM()
                    {
                        MobileId = tempMobile.Id, ImageBinary = target.ToArray()
                    });
                }
            }


            return(RedirectToAction("/New"));
        }
Пример #6
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,
            }));
        }
Пример #7
0
 public MobileM Save(MobileM mobile)
 {
     return(mobileRepository.Save(mobile));
 }
Пример #8
0
 public MobileM Edit(MobileM mobile)
 {
     return(mobileRepository.Edit(mobile));
 }