public Projects GetProjects([FromRoute] int id) { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} //var projects = await _context.Projects.FindAsync(id); Projects project = new Projects(); using (var bdContext = new HOCContext()) { return(project = (from r in bdContext.Projects where r.Id == id select(new Projects { Id = r.Id, Name = r.Name, Description = r.Description, Approved = r.Approved, ApprovedOn = r.ApprovedOn, ApprovedBy = r.ApprovedBy, StartDate = r.StartDate, EndDate = r.EndDate, CreatedOn = r.CreatedOn, CreatedBy = r.CreatedBy, ModifiedOn = r.ModifiedOn, ModifiedBy = r.ModifiedBy, Stage = r.Stage })).FirstOrDefault()); } }
public void SaveProject() { //if (!ModelState.IsValid) //{ // return BadRequest(ModelState); //} try { using (var bdContext = new HOCContext()) { //_context.Projects.Add(projects); Projects P1 = new Projects(); P1.Name = "Test2"; P1.Description = "Description"; P1.CreatedBy = 1; P1.ModifiedBy = 1; P1.ModifiedOn = DateTime.Today; P1.Stage = 0; bdContext.Projects.Add(P1); bdContext.SaveChanges(); //return CreatedAtAction("GetProjects", new { id = P1.Id }, projects); } } catch (Exception ex) { } }
public IList <Projects> GetProjects() { try { List <Projects> projects = new List <Projects>(); using (var bdContext = new HOCContext()) { return(projects = (from r in bdContext.Projects select(new Projects { Id = r.Id, Name = r.Name, Description = r.Description, Approved = r.Approved, ApprovedOn = r.ApprovedOn, ApprovedBy = r.ApprovedBy, StartDate = r.StartDate, EndDate = r.EndDate, CreatedOn = r.CreatedOn, CreatedBy = r.CreatedBy, ModifiedOn = r.ModifiedOn, ModifiedBy = r.ModifiedBy, Stage = r.Stage, })).ToList()); } // return projects; }catch (Exception ex) { return(null); throw ex; } }
public async Task <IActionResult> PostProjects([FromBody] Projects projects) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } using (var bdContext = new HOCContext()) { _context.Projects.Add(projects); Projects P1 = new Projects(); P1.Name = "Test2"; P1.Description = "Description"; P1.CreatedBy = 1; P1.ModifiedBy = 1; P1.ModifiedOn = DateTime.Today; P1.Stage = 0; bdContext.Projects.Add(P1); bdContext.SaveChanges(); } try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (ProjectsExists(projects.Id)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetProjects", new { id = projects.Id }, projects)); }
public DashboardController(HOCContext context) { _context = context; }
public ApprovalController(HOCContext _context) { this.context = _context; }
public UserController(HOCContext context) { _context = context; }
public ProjectsController(HOCContext context) { _context = context; }
public ScheduleController(HOCContext context) { _context = context; }
public ApprovalsDashboardController(HOCContext context) { _context = context; }
public OrganizerController(HOCContext _context) { this.context = _context; }