示例#1
0
        public IActionResult Post([FromBody] Registry registry)
        {
            if (registry == null)
            {
                return(BadRequest());
            }

            _ctx.Registries.Add(registry);
            _ctx.SaveChanges();

            return(CreatedAtRoute("GetPublicKey", new { phoneNumber = registry.PhoneNumber }, registry));
        }
示例#2
0
        public void CreateEmployeeAudit()
        {
            context.Employees.Add(new Employee()
            {
                Name     = "Test User",
                Position = "Tester"
            });
            context.SaveChanges();

            AuditMessage message = context.AuditMessages.OrderByDescending(x => x.Date).First();

            Assert.AreEqual("Employee \"Test User\" (Tester) was added.", message.Message);
        }
示例#3
0
 public ActionResult Create(Student student, int CourseId)
 {
     _db.Students.Add(student);
     if (CourseId != 0)
     {
         _db.CourseStudent.Add(new CourseStudent()
         {
             CourseId = CourseId, StudentId = student.StudentId
         });
     }
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        //Deleta um time
        public void DeleteStudent(int id)
        {
            var Student = _context.Student.Find(id);

            _context.Student.Remove(Student);
            _context.SaveChanges();
        }
示例#5
0
        //Deleta um time
        public void DeleteHistoric(int id)
        {
            var Historic = _context.Historic.Find(id);

            _context.Historic.Remove(Historic);
            _context.SaveChanges();
        }
        //Deleta um time
        public void DeleteClass(int id)
        {
            var Class = _context.Class.Find(id);

            _context.Class.Remove(Class);
            _context.SaveChanges();
        }
示例#7
0
        //Deleta um time
        public void DeleteRequirement(int id)
        {
            var Requirement = _context.Requirement.Find(id);

            _context.Requirement.Remove(Requirement);
            _context.SaveChanges();
        }
示例#8
0
        //Deleta um time
        public void DeleteSubject(int id)
        {
            var Subject = _context.Subject.Find(id);

            _context.Subject.Remove(Subject);
            _context.SaveChanges();
        }
示例#9
0
 public Employee Post(Employee employee)
 {
     using (var context = new RegistryContext())
     {
         context.Employees.Add(employee);
         context.SaveChanges();
         return(employee);
     }
 }
示例#10
0
 public Task Post(Task task)
 {
     using (var context = new RegistryContext())
     {
         context.Tasks.Add(task);
         context.SaveChanges();
         return(task);
     }
 }
示例#11
0
 public Time Post(Time time)
 {
     using (var context = new RegistryContext())
     {
         context.Times.Add(time);
         context.SaveChanges();
         return(time);
     }
 }
示例#12
0
 public bool Delete(int id)
 {
     using (var context = new RegistryContext())
     {
         var employeeDel = context.Employees.FirstOrDefault(x => x.id == id);
         context.Employees.Remove(employeeDel);
         context.SaveChanges();
         return(true);
     }
 }
示例#13
0
 public Employee Put(Employee employee)
 {
     using (var context = new RegistryContext())
     {
         var employeeAct = context.Employees.FirstOrDefault(x => x.id == employee.id);
         employeeAct.name     = employee.name;
         employeeAct.password = employee.password;
         employeeAct.tasks    = employee.tasks;
         context.SaveChanges();
         return(employee);
     }
 }
示例#14
0
 public Task Put(Task task)
 {
     using (var context = new RegistryContext())
     {
         var taskAct = context.Tasks.FirstOrDefault(x => x.id == task.id);
         taskAct.name        = task.name;
         taskAct.description = task.description;
         taskAct.employeeId  = task.employeeId;
         context.SaveChanges();
         return(task);
     }
 }
示例#15
0
 public Time Put(Time time)
 {
     using (var context = new RegistryContext())
     {
         var timeAct = context.Times.FirstOrDefault(x => x.id == time.id);
         timeAct.date   = time.date;
         timeAct.hours  = time.hours;
         timeAct.taskId = time.taskId;
         context.SaveChanges();
         return(time);
     }
 }
示例#16
0
        public void CreateAndReadEmployee()
        {
            // verify that we're starting empty
            Assert.AreEqual(0, context.Employees.Count());

            // create a new employee
            context.Employees.Add(new Employee()
            {
                Name     = "Test User",
                Position = "Tester"
            });
            context.SaveChanges();

            // verify we have 1 employee
            Assert.AreEqual(1, context.Employees.Count());

            // fetch employee from db, and data matches
            Employee employee = context.Employees.First();

            Assert.AreEqual("Test User", employee.Name);
            Assert.AreEqual("Tester", employee.Position);
        }
        public void InitilizeTest()
        {
            context.Employees.Add(new Employee()
            {
                Name     = "Test User",
                Position = "Tester"
            });
            context.SaveChanges();

            EmployeeListViewModel vm = new EmployeeListViewModel(context);

            Assert.AreEqual("Test User", vm.Employees.First().Name);
            Assert.IsTrue(vm.IsNotEmployeeSelected);
            Assert.AreEqual("Employee \"Test User\" (Tester) was added.", vm.AuditMessages.First().Message);
        }
示例#18
0
        static void Main(string[] args)
        {
            var User = new User()
            {
                IdFuckYou = "laina",
                Email     = "Laina",
                Password  = "******"
            };
            var ctx = new RegistryContext();

            ctx.Users.Add(User);

            ctx.SaveChanges();

            Console.WriteLine("DONE");
        }
示例#19
0
        private static RegistryContext GetTest1Context()
        {
            var options = new DbContextOptionsBuilder <RegistryContext>()
                          .UseInMemoryDatabase(databaseName: "RegistryDatabase-" + Guid.NewGuid())
                          .Options;

            // Insert seed data into the database using one instance of the context
            using (var context = new RegistryContext(options))
            {
                var entity = new Organization
                {
                    Slug         = MagicStrings.PublicOrganizationSlug,
                    Name         = "Public",
                    CreationDate = DateTime.Now,
                    Description  = "Public organization",
                    IsPublic     = true,
                    OwnerId      = null
                };
                var ds = new Dataset
                {
                    Slug = MagicStrings.DefaultDatasetSlug,
                    //Name = "Default",
                    //IsPublic = true,
                    CreationDate = DateTime.Now,
                    //LastUpdate = DateTime.Now,
                    InternalRef = Guid.Parse("0a223495-84a0-4c15-b425-c7ef88110e75")
                };

                entity.Datasets = new List <Dataset> {
                    ds
                };

                context.Organizations.Add(entity);

                context.SaveChanges();
            }

            return(new RegistryContext(options));
        }
示例#20
0
 public ActionResult Create(Course course)
 {
     _db.Courses.Add(course);
     _db.SaveChanges();
     return(RedirectToAction("Index"));
 }