Ejemplo n.º 1
0
 // GET api/assignment
 public IEnumerable<AssignmentModel> Get()
 {
     using (BasicDao context = new BasicDao()) {
         var allAssignments = context.GetAll<ProjectAssignment>().Select(x => new AssignmentModel() { Id = x.Id, PersonId = x.PersonId, PersonUsername = x.Person.Username, ProjectId = x.ProjectId }).ToList();
         return allAssignments;
     }
 }
Ejemplo n.º 2
0
 // POST api/assignment
 public ProjectAssignment Post(AssignmentModel model)
 {
     using (BasicDao context = new BasicDao()) {
         ProjectAssignment newAssignment = new ProjectAssignment();
         newAssignment.PersonId = model.PersonId;
         newAssignment.ProjectId = model.ProjectId;
         context.Insert(newAssignment);
         return newAssignment;
     }
 }
 internal void CreateProject(ProjectModel projectModel)
 {
     using (BasicDao context = new BasicDao()) {
         Project newProject = new Project();
         newProject.Name = projectModel.Name;
         newProject.Code = projectModel.Code;
         newProject.Budget = projectModel.Budget;
         newProject.Remarks = projectModel.Remarks;
         context.Insert(newProject);
     }
 }
 internal void CreatePerson(PersonModel personModel)
 {
     using (BasicDao context = new BasicDao()) {
         Person newPerson = new Person();
         newPerson.Username = personModel.Username;
         newPerson.Password = personModel.Password;
         newPerson.FirstName = personModel.FirstName;
         newPerson.LastName = personModel.LastName;
         context.Insert(newPerson);
     }
 }
Ejemplo n.º 5
0
 // DELETE api/assignment/5
 public void Delete(int id)
 {
     using (BasicDao context = new BasicDao()) {
         context.Delete<ProjectAssignment>(id);
     }
 }
Ejemplo n.º 6
0
 internal void PopulateProjects()
 {
     using (BasicDao context = new BasicDao()) {
         Projects = context.db.Projects.Select(x => new ProjectModel() { Id=x.Id, Name=x.Name, Budget=x.Budget }).ToList();
     }
 }