예제 #1
0
        public async Task <ActionResult <IOSDevice> > PostIOSDevice(IOSDevice iOSDevice)
        {
            _context.IOSDevices.Add(iOSDevice);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetIOSDevice", new { id = iOSDevice.Id }, iOSDevice));
        }
예제 #2
0
        public async Task <IActionResult> PutIOSDevice(int id, IOSDevice iOSDevice)
        {
            if (id != iOSDevice.Id)
            {
                return(BadRequest());
            }

            _context.Entry(iOSDevice).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!IOSDeviceExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
예제 #3
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,DeviceName,DeviceIdentifier,DeviceModel,StringDeviceConfiguration,StringYear,Year")] IOSDevice iOSDevice)
        {
            if (id != iOSDevice.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(iOSDevice);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!IOSDeviceExists(iOSDevice.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(iOSDevice));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("Id,DeviceName,DeviceIdentifier,DeviceModel,StringDeviceConfiguration,StringYear,Year")] IOSDevice iOSDevice)
        {
            if (ModelState.IsValid)
            {
                _context.Add(iOSDevice);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(iOSDevice));
        }
예제 #5
0
        /// <summary>
        /// Takes a serial number in and first checks the stored list of
        /// known serial numbers from the database. If it is not found,
        /// it makes a call to apples web api using the DeviceID class.
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public IActionResult GetSN(GeneralViewModel search)
        {
            string     str      = search.NewSearch.SearchText.ToString();
            string     lastFour = search.NewSearch.SearchText.ToString().Substring(str.Length - 4);
            LastFourSN lfsn     = _context.LastFourSNs.FirstOrDefault(m => m.last4 == lastFour);

            GeneralViewModel gvm = new GeneralViewModel();

            if (lfsn == null)
            {
                DeviceID dId      = new DeviceID();
                string   itemName = dId.AppleSNLookup(str);
                gvm.DeviceName = itemName;
            }
            else
            {
                gvm.DeviceName = lfsn.name;
            }



            Computer computer = _context.Computers.Search(
                m => m.Model.ToLower(),
                m => m.Description.ToLower(),
                m => m.ModelIdentifier.ToLower())
                                .Containing(gvm.DeviceName.ToLower()).FirstOrDefault();

            IOSDevice iOSDevice = _context.IOSDevices.Search(
                m => m.DeviceName.ToLower(),
                m => m.DeviceModel.ToLower(),
                m => m.DeviceConfiguration.Configuration.ToLower(),
                m => m.DeviceModelNumber.Model.ToLower())
                                  .Containing(gvm.DeviceName.ToLower()).FirstOrDefault();


            if (computer != null)
            {
                gvm.Computer = computer;
                return(RedirectToAction("details", "Computers", new { id = computer.Id }));
            }
            if (iOSDevice != null)
            {
                gvm.IOSDevice = iOSDevice;
                return(RedirectToAction("details", "IOSDevices", new { id = iOSDevice.Id }));
            }
            else
            {
                return(View("Index", gvm));
            }
        }