Esempio n. 1
0
        public static void Initialize(ApplicationDbContext context)
        {
            context.Database.EnsureCreated();

            // Look for any students.
            if (context.Persons.Any())
            {
                return;   // DB has been seeded
            }

            var usersLogin = new PersonsData[]
            {
                new PersonsData {
                    Name = "Ультра", Color = "Чёрный+Красный", Speed = 50, Size = 30, User = "******"
                },
                new PersonsData {
                    Name = "Черепаха", Color = "Чёрный+Красный", Speed = 10, Size = 30, User = "******"
                },
                new PersonsData {
                    Name = "Test", Color = "Чёрный+Красный", Speed = 10, Size = 10, User = "******"
                },
            };

            foreach (PersonsData s in usersLogin)
            {
                context.Persons.Add(s);
            }
            context.SaveChanges();
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Age,Sex")] PersonsData personsData)
        {
            if (id != personsData.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(personsData);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PersonsDataExists(personsData.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(personsData));
        }
        public async Task <IActionResult> Create([Bind("ID,Name,Age,Sex")] PersonsData personsData)
        {
            if (ModelState.IsValid)
            {
                _context.Add(personsData);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(personsData));
        }
Esempio n. 4
0
        public void Setup()
        {
            // Arrange
            model = new PersonsData {
                PersonsID = 1, Name = "AAA", Speed = 20, Size = 20
            };
            modelBusiness = new PersonsBusiness {
                PersonsID = 2, Name = "BBB", Color = "Чёрный+зелёный"
            };

            personsDataService = new Mock <IPersonsDataService>();

            personsService = new PersonsBusinessService(personsDataService.Object);
        }
 public async Task UpdatePers(PersonsData persons, string name)
 {
     this.db.Persons.Update(persons);
     await this.db.SaveChangesAsync();
 }
Esempio n. 6
0
 private void DeleteMeasurement(object obj)
 {
     PersonsData.Remove((PersonViewModel)obj);
     SelectedPersonsData = null;
 }
Esempio n. 7
0
 private static void Main(string[] args)
 {
     PersonsData.GetPersons();
     NoOfMales.GetNoOfMales();
 }