Esempio n. 1
0
        public async Task <IActionResult> PutPerson([FromRoute] Guid id, [FromBody] Person person)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != person.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Esempio n. 2
0
        public async Task <IActionResult> Create([Bind("Id,LastName,FirstName")] Person person)
        {
            if (ModelState.IsValid)
            {
                person.Id = Guid.NewGuid();
                _context.Add(person);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(person));
        }
Esempio n. 3
0
        public async Task <Guid> Upsert(Processor model)
        {
            model.Brand     = _appContext.Brands.Find(model.Brand.Id);
            model.CpuSocket = _appContext.CpuSockets.Find(model.CpuSocket.Id);
            model.RamType   = _appContext.RamTypes.Find(model.RamType.Id);

            _appContext.Processors.Update(model);
            await _appContext.SaveChangesAsync();

            return(model.Id.Value);
        }
        public async Task TestMethod()
        {
            var postalcode = await _context.PostalCodes.ToListAsync();

            //var properties = await _context.Properties.OrderBy(x => x.Id).ToListAsync();
            //int count = 100000;

            //var list1 = properties.Take(count).ToList();
            //var list2 = properties.Skip(count).Take(count).ToList();
            //var list3 = properties.Skip(2 * count).Take(count).ToList();
            //var list4 = properties.Skip(3 * count).Take(count).ToList();
            //var list5 = properties.Skip(4 * count).Take(count).ToList();
            //var list6 = properties.Skip(5 * count).Take(count).ToList();
            //var list7 = properties.Skip(6 * count).ToList();

            foreach (var item in postalcode)
            {
                var stringa = item.Code;
                if (stringa == null)
                {
                    item.OutCode = 0;
                }
                else
                {
                    var correct = stringa.Replace("OUTCODE%5E", "");

                    var number = Convert.ToInt32(correct);

                    item.OutCode = number;
                }
                _context.PostalCodes.Update(item);
            }
            await _context.SaveChangesAsync();

            //foreach (var item in list7)
            //{
            //    var stringa = item.PostalCode.ToString();
            //    var first = stringa.Split(" ")[0];
            //    var end = stringa.Split(" ")[1];
            //    item.PostalCodeExtended = first;
            //    item.PostalCodePrefix = string.Join("", Regex.Matches(first, @"[A-Z]").Select(x => x.Value));
            //    var endDigits = Regex.Match(end, @"[0-9]").Value;
            //    item.PostalCodeFull = first + " " + endDigits;
            //     _context.Properties.Update(item);
            //}

            //await _context.SaveChangesAsync();
        }
Esempio n. 5
0
 public async void Delete(Guid id)
 {
     _appContext.VideoCards.Remove(_appContext.VideoCards.Find(id));
     await _appContext.SaveChangesAsync();
 }
Esempio n. 6
0
 public async void Delete(Guid id)
 {
     _appContext.StorageDrives.Remove(_appContext.StorageDrives.Find(id));
     await _appContext.SaveChangesAsync();
 }
Esempio n. 7
0
 public async void Delete(Guid id)
 {
     _appContext.PowerSuplies.Remove(_appContext.PowerSuplies.Find(id));
     await _appContext.SaveChangesAsync();
 }