示例#1
0
        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());
            }
        }
示例#2
0
 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)
     {
     }
 }
示例#3
0
        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;
            }
        }
示例#4
0
        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));
        }
示例#5
0
 public DashboardController(HOCContext context)
 {
     _context = context;
 }
示例#6
0
        public ApprovalController(HOCContext _context)

        {
            this.context = _context;
        }
示例#7
0
 public UserController(HOCContext context)
 {
     _context = context;
 }
示例#8
0
 public ProjectsController(HOCContext context)
 {
     _context = context;
 }
示例#9
0
 public ScheduleController(HOCContext context)
 {
     _context = context;
 }
 public ApprovalsDashboardController(HOCContext context)
 {
     _context = context;
 }
示例#11
0
        public OrganizerController(HOCContext _context)

        {
            this.context = _context;
        }