public ActionResult Edit(MobileDTO mobileDTO) { CustomerM admin = authService.DecodeJWT(User.Identity.Name); ShopMobilesM shopMobiles = shopMobilesService.FindByShopAndMobile(admin.ShopAdminId, mobileDTO.Id); if (shopMobiles != null) { shopMobiles.Price = mobileDTO.Price; shopMobiles.MobilesLeft = mobileDTO.Amount; shopMobilesService.Edit(shopMobiles); } return(RedirectToAction("Manage")); }
public ShopMobilesM Save(ShopMobilesM shopMobiles) { Shop_Mobiles shopMobilesDb = new Shop_Mobiles() { MobileId = shopMobiles.MobileId, MobilesLeft = shopMobiles.MobilesLeft, ShopId = shopMobiles.ShopId, Price = shopMobiles.Price, }; Context.Shop_Mobiles.Add(shopMobilesDb); Context.SaveChanges(); shopMobiles.Id = shopMobilesDb.Id; return(shopMobiles); }
public ShopMobilesM Edit(ShopMobilesM shopMobiles) { var found = Context.Shop_Mobiles.SingleOrDefault(x => x.Id == shopMobiles.Id); if (found == null) { return(null); } found.ShopId = shopMobiles.ShopId; found.MobilesLeft = shopMobiles.MobilesLeft; found.MobileId = shopMobiles.MobileId; found.Price = shopMobiles.Price; Context.SaveChanges(); return(shopMobiles); }
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)); }
public ActionResult Add(MobileShopDTO mobileShop) { CustomerM customer = authService.DecodeJWT(User.Identity.Name); ShopMobilesM foundPair = shopMobilesService.FindByShopAndMobile(customer.ShopAdminId, mobileShop.MobileId); if (foundPair == null) { shopMobilesService.Save(new ShopMobilesM() { MobileId = mobileShop.MobileId, MobilesLeft = mobileShop.Amount, ShopId = customer.ShopAdminId, Price = mobileShop.Price, }); } return(RedirectToAction("All")); }
public ActionResult Accept(int id) { ShoppingM shopping = shoppingService.FindById(id); CustomerM customer = authService.DecodeJWT(User.Identity.Name); ShopMobilesM shopMobiles = shopMobilesService.FindByShopAndMobile(shopping.ShopId, shopping.MobileId); if (shopping == null || shopping.Status != "Pending" || shopMobiles == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } if (shopping.ShopId != customer.ShopAdminId) { return(new HttpStatusCodeResult(HttpStatusCode.Unauthorized)); } shopping.Status = "Accepted"; shoppingService.Edit(shopping); shopMobiles.MobilesLeft--; shopMobilesService.Edit(shopMobiles); return(new HttpStatusCodeResult(HttpStatusCode.OK)); }
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, })); }
public ShopMobilesM Save(ShopMobilesM shopMobiles) { return(shopMobilesRepository.Save(shopMobiles)); }
public ShopMobilesM Edit(ShopMobilesM shopMobiles) { return(shopMobilesRepository.Edit(shopMobiles)); }