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)); }
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); }
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(); }
//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(); }
//Deleta um time public void DeleteRequirement(int id) { var Requirement = _context.Requirement.Find(id); _context.Requirement.Remove(Requirement); _context.SaveChanges(); }
//Deleta um time public void DeleteSubject(int id) { var Subject = _context.Subject.Find(id); _context.Subject.Remove(Subject); _context.SaveChanges(); }
public Employee Post(Employee employee) { using (var context = new RegistryContext()) { context.Employees.Add(employee); context.SaveChanges(); return(employee); } }
public Task Post(Task task) { using (var context = new RegistryContext()) { context.Tasks.Add(task); context.SaveChanges(); return(task); } }
public Time Post(Time time) { using (var context = new RegistryContext()) { context.Times.Add(time); context.SaveChanges(); return(time); } }
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); } }
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); } }
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); } }
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); } }
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); }
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"); }
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)); }
public ActionResult Create(Course course) { _db.Courses.Add(course); _db.SaveChanges(); return(RedirectToAction("Index")); }