123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- using Microsoft.AspNetCore.Http;
- using Microsoft.AspNetCore.Mvc;
- using Microsoft.EntityFrameworkCore;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- using wispro.sp.entity;
- using wispro.sp.share;
- namespace wispro.sp.api.Controllers
- {
- [Route("api/[controller]/[action]")]
- [ApiController]
- public class ProjectController : ControllerBase
- {
- spDbContext Context;
-
- public ProjectController(spDbContext context)
- {
- Context = context;
-
- }
- public List<ProjectInfo> GetProjects(int state)
- {
- return Context.ProjectInfos
- .Include(p => p.Customer)
- .Include(p=>p.Reviewer)
- .Include(p => p.WorkflowUser)
- .Where(s => s.CaseState == state).ToList();
- }
- public List<ProjectInfo> GetAll()
- {
- var retList = Context.ProjectInfos
- .Include(p => p.Customer)
- .Include(p => p.Reviewer)
- .Include(p => p.WorkflowUser)
- .ToList();
- return retList;
- }
-
- public bool SetFinished(string caseNo)
- {
- var obj = Context.ProjectInfos.FirstOrDefault(s=>s.CaseNo == caseNo );
- if(obj != null)
- {
- try
- {
- obj.CaseState = 4;
- Context.SaveChanges();
- return true;
- }
- catch(Exception ex)
- {
- return false;
- }
- }
- else
- {
- return false;
- }
- }
- public List<ProjectContentRecord> GetMyProjects()
- {
- return Context.ProjectContentRecords
- .Include(p=>p.CalMonth)
- .Include(p => p.Reviewer)
- .Include(p => p.Project)
- .Include(p=>p.ProjectWorkContents)
- .Where(p => p.Staff.Name == User.Identity.Name).ToList();
- }
- public ProjectContents getProjectWorkContent(int Id)
- {
- var retObj = Context.ProjectContentRecords
- .Include(p => p.CalMonth)
- .Include(p => p.Reviewer)
- .Include(p => p.Project)
- .Include(p => p.ProjectWorkContents)
- .FirstOrDefault(p=>p.Id == Id);
- if(retObj != null)
- {
- ProjectContents ret = new ProjectContents();
- ret.ProjectContentRecord = retObj;
- ret.ProjectWorkContents = new List<ViewProjectWorkContent>();
- foreach(var wContent in retObj.ProjectWorkContents)
- {
- ViewProjectWorkContent tem = new ViewProjectWorkContent();
- tem.modifyState = ModifyState.UnChanged;
- tem.Content = wContent.Content;
- tem.ActualPerformance = wContent.ActualPerformance;
- tem.ContentRecordId = wContent.ContentRecordId;
- tem.FinalPerformance = wContent.FinalPerformance;
- tem.TakeTime = wContent.TakeTime;
- tem.TimeSpan = wContent.TimeSpan;
- tem.WorkDate = wContent.WorkDate;
- ret.ProjectWorkContents.Add(tem);
- }
- return ret;
- }
- return null;
- }
- public ApiSaveResponse SaveProjectWorkContent(ProjectContents saveObj)
- {
- return null;
- }
- }
- }
|