public static void RegisterNewApplication(ClearanceFormApplication app) { var db = new DatabaseEntities(); db.Applications.Add(app.Application); db.SaveChanges(); List <Form_Approver> faList = db.Form_Approver.ToList(); faList = (from f in faList where f.FormID == app.Application.FormID select f).ToList(); db.ClearanceFormFinalResultDates.Add(new ClearanceFormFinalResultDate() { ApplicationID = app.Application.ApplicationID, FinalResultDate = app.FinalResultDate }); db.SaveChanges(); Workflow wf = new Workflow() { AppliationID = app.Application.ApplicationID, ApproverID = faList.ElementAt(0).ApproverID, Status = 1, Order = faList.ElementAt(0).ApprovalOrder, Time = app.Application.CreatedOn }; db.Workflows.Add(wf); for (int i = 1; i < faList.Count; i++) { wf = new Workflow() { AppliationID = app.Application.ApplicationID, ApproverID = faList.ElementAt(i).ApproverID, Status = 4, Order = faList.ElementAt(i).ApprovalOrder, Time = app.Application.CreatedOn }; db.Workflows.Add(wf); } db.SaveChanges(); }
public static ClearanceFormApplication GetApplicationInformationForThisContributor(int app_id, int contributor) { var db = new DatabaseEntities(); List <Workflow> workflows = db.Workflows.ToList(); var y = (from w in workflows where w.AppliationID == app_id && w.ApproverID == contributor select w).ToList(); if (y.Count == 0) { return(null); } List <Application> apps = db.Applications.ToList(); List <Workflow> list = (from w in workflows where w.AppliationID == app_id select w).ToList(); var x = (from a in apps where a.ApplicationID == app_id select a).ToList(); List <User> users = db.Users.ToList(); var u = (from user in users where user.UserId == x.ElementAt(0).UserID select user).ToList(); var finalResultDates = db.ClearanceFormFinalResultDates.ToList(); var fDate = (from date in finalResultDates where date.ApplicationID == x.ElementAt(0).ApplicationID select date).ToList(); ClearanceFormApplication cfa = new ClearanceFormApplication() { Application = x.ElementAt(0), RollNumber = u.ElementAt(0).Login, WorkFlows = list, FinalResultDate = fDate.ElementAt(0).FinalResultDate }; return(cfa); }
public static ClearanceFormApplication GetApplicationInformationOfThisUser(int app_id, int user_id, String rollNumber) { var db = new DatabaseEntities(); List <Application> apps = db.Applications.ToList(); var y = (from a in apps where a.ApplicationID == app_id && a.UserID == user_id select a).ToList(); if (y.Count == 0) { return(null); } List <Workflow> workflows = db.Workflows.ToList(); var finalResultDates = db.ClearanceFormFinalResultDates.ToList(); var fDate = (from date in finalResultDates where date.ApplicationID == app_id select date).ToList(); List <Workflow> wfs = (from wf in workflows where wf.AppliationID == app_id select wf).ToList(); ClearanceFormApplication cfa = new ClearanceFormApplication() { Application = y.ElementAt(0), RollNumber = rollNumber, WorkFlows = wfs, FinalResultDate = fDate.ElementAt(0).FinalResultDate }; return(cfa); }