public void ActionOnReport(int? expenseId, Employee employee,ReportStatus status) { //IEmployeeService employeeService = new EmployeeService(); //Employee employee = employeeService.GetEmployee((int)Membership.GetUser().ProviderUserKey); using (EMEntitiesContext ctx = new EMEntitiesContext()) { var report = (from ExpReport in ctx.ExpenseReports where ExpReport.ExpenseId == expenseId select ExpReport).FirstOrDefault(); //if (action == "Approve") //{ report.ApprovedDate = DateTime.Now; //report.Status = "ApprovedBySupervisor"; report.Status = status.ToString(); report.ApprovedById = employee.UserId; ctx.SaveChanges(); //} //else //{ // report.ApprovedDate = DateTime.Now; // report.Status = "RejectedBySupervisor"; // report.ApprovedById = employee.UserId; // ctx.SaveChanges(); //} } }
public void ProcessReport(int? expenseId, Employee employee, ReportStatus status) { using (EMEntitiesContext ctx = new EMEntitiesContext()) { var report = (from ExpReport in ctx.ExpenseReports where ExpReport.ExpenseId == expenseId select ExpReport).FirstOrDefault(); report.ProcessedDate = DateTime.Now; report.Status = status.ToString(); report.ProcessedById = employee.UserId; ctx.SaveChanges(); } }
public void InsertExpenseReport(ExpenseReport report) { using (EMEntitiesContext ctx = new EMEntitiesContext()) { ExpenseReport newReport = new ExpenseReport(); newReport.CreatedBy = ctx.Employees.First(e => e.UserId == report.CreatedBy.UserId); newReport.CreateDate = report.CreateDate; newReport.Department = ctx.Departments.First(d => d.DepartmentId == report.Department.DepartmentId); newReport.Status = ReportStatus.Submitted.ToString(); newReport.ExpenseItems = report.ExpenseItems; ctx.ExpenseReports.Add(newReport); ctx.SaveChanges(); } }