public BatteryM Save(BatteryM battery) { Battery batteryDb = new Battery() { Capacity = battery.Capacity }; batteryDb = Context.Batteries.Add(batteryDb); Context.SaveChanges(); battery.Id = batteryDb.Id; return(battery); }
public BatteryM Edit(BatteryM battery) { var found = Context.Batteries.SingleOrDefault(x => x.Id == battery.Id); if (found == null) { return(null); } found.Capacity = battery.Capacity; Context.SaveChanges(); return(battery); }
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")); }
public BatteryM Save(BatteryM battery) { return(batteryRepository.Save(battery)); }
public BatteryM Edit(BatteryM battery) { return(batteryRepository.Edit(battery)); }
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, })); }