public async Task <bool> UpdateEmp(EmpModel empModel) { var job = await _context.Job.FindAsync(empModel.JobTitleId); var emp = await _context.Employees.FindAsync(empModel.EmpId); emp.EmpFName = empModel.EmpFName; emp.EmpLName = empModel.EmpLName; emp.Email = empModel.Email; emp.JobTitleId = empModel.JobTitleId; emp.WorkSince = empModel.WorkSince; emp.Gender = empModel.Gender; emp.Mobile = empModel.Mobile.HasValue ? empModel.Mobile.Value : 0; emp.Dob = empModel.Dob; emp.Address = empModel.Address; emp.ProfilePhoto = empModel.PhotoURL; emp.Status = empModel.Status; emp.Designation = job.JobName; emp.CasualAllocated = job.Casual; emp.AnnualAllocated = job.Annual; emp.MedicalAllocated = job.Medical; emp.ShortLeaveAllocated = job.ShortLeaves; emp.HalfLeaveAllocated = job.HalfDays; emp.FromDate = empModel.WorkSince.AddMonths(1); emp.Todate = empModel.WorkSince.AddMonths(1).AddYears(1); _context.Entry(emp).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <bool> ApproveAttendence(int id, String name) { String content = "Your Attendence request below has been approved"; await EmailSend(id, content); var attendence = await _context.Attendence.FindAsync(id); attendence.Status = "Approved"; attendence.Approver = name; _context.Entry(attendence).State = EntityState.Modified; await _context.SaveChangesAsync(); DateTime date = (DateTime)attendence.Date; var info = _context.MarkAttendence.SingleOrDefault(x => (x.EmpId == attendence.EmpId) && (x.Date == date.Date)); if (info == null) { var markAttendence = new MarkAttendence() { Date = attendence.Date, InTime = attendence.InTime, OutTime = attendence.OutTime, TotalHours = attendence.TotalHours, EmpId = attendence.EmpId, Type = "Manual", Status = "Present", EmailSent = true, }; await _context.MarkAttendence.AddAsync(markAttendence); await _context.SaveChangesAsync(); } else { info.InTime = attendence.InTime; info.OutTime = attendence.OutTime; info.TotalHours = attendence.TotalHours; info.Type = "Manual"; info.Status = "Present"; info.EmailSent = true; _context.Entry(info).State = EntityState.Modified; await _context.SaveChangesAsync(); } return(true); }
public async Task <bool> CompleteTask(int id) { var task = await _context.Tasks.FindAsync(id); task.TimeSheet = true; _context.Entry(task).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <bool> EditProject(Project project) { var proj = await _context.Projects.FindAsync(project.Id); proj.Description = project.Description; proj.Name = project.Name; proj.Type = project.Type; proj.StartDate = project.StartDate; proj.DeliveryDate = project.DeliveryDate; proj.LastUpdate = DateTime.Now; proj.ContractValue = project.ContractValue; proj.EstimetedBudget = project.EstimetedBudget; proj.EmployeesId = project.ProjectManagerId; proj.CustomersId = project.CustomerId; proj.Status = project.Status; proj.Cost = project.Cost + project.ExtraCost; if (project.Status == "Closed") { proj.ClosedDate = DateTime.Now; } _context.Entry(proj).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <bool> Updatejob(JobModel jobModel) { var job = await _context.Job.FindAsync(jobModel.JobId); job.JobName = jobModel.JobName; job.Casual = jobModel.Casual.HasValue ? jobModel.Casual.Value : 0; job.Annual = jobModel.Annual.HasValue ? jobModel.Annual.Value : 0; job.Medical = jobModel.Medical.HasValue ? jobModel.Medical.Value : 0; job.ShortLeaves = jobModel.ShortLeaves.HasValue ? jobModel.ShortLeaves.Value : 0; job.HalfDays = jobModel.HalfDays.HasValue ? jobModel.HalfDays.Value : 0; _context.Entry(job).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <int> InTimeMark(TimeTrackerModel timeTrackerModel) { var timeTracker = new TimeTracker() { Date = DateTime.Now.Date, InTime = DateTime.Now, TotalHours = 0, WorkingHours = 0, BreakingHours = 0, EmpId = timeTrackerModel.EmpId, Status = "Work", Inlocation = timeTrackerModel.Inlocation, Inlatitude = timeTrackerModel.Inlatitude, InLongitude = timeTrackerModel.InLongitude }; await _context.TimeTracker.AddAsync(timeTracker); await _context.SaveChangesAsync(); var info = _context.MarkAttendence.SingleOrDefault(x => (x.EmpId == timeTrackerModel.EmpId) && (x.Date == DateTime.Now.Date)); if (info == null) { var markAttendence = new MarkAttendence() { Date = DateTime.Now.Date, InTime = DateTime.Now, OutTime = null, TotalHours = 0, EmpId = timeTrackerModel.EmpId, Type = "Auto", Status = "Absent", EmailSent = false }; await _context.MarkAttendence.AddAsync(markAttendence); await _context.SaveChangesAsync(); } else { info.InTime = DateTime.Now; info.Type = "Auto"; info.Status = "Absent"; info.EmailSent = false; _context.Entry(info).State = EntityState.Modified; await _context.SaveChangesAsync(); } return(timeTracker.TrackId); }
public async Task <bool> RecommendLeave(int id, String name) { String content = "The leave request below has been recommended. Now It's waiting for getting approval"; await EmailSend(id, content); var leave = await _context.LeaveApply.FindAsync(id); leave.Status = "Waiting for Approval"; leave.RecommendName = name; _context.Entry(leave).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <bool> EditCustomer(Customer customers) { var cus = await _context.Customers.FindAsync(customers.Id); cus.Name = customers.Name; cus.Address = customers.Address; cus.ContactNo = customers.ContactNo; cus.Email = customers.Email; _context.Entry(cus).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <bool> EditCustomers(CustomerModel customer) { var cus = await _context.PreSalesCustomers.FindAsync(customer.Id); cus.name = customer.name; cus.address = customer.address; cus.contactNumber = customer.contactNumber; cus.emailAddress = customer.emailAddress; cus.projectCount = customer.projectCount; _context.Entry(cus).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <bool> AddCost(int id, DateTime Start, DateTime End) { var taskInfo = await _context.Tasks.FindAsync(id); int projectId = taskInfo.ProjectsId; int empId = taskInfo.EmployeesId; var emp = await _context.Employees.FindAsync(empId); Double rate = await _context.Salarys.Where(x => x.Designation == emp.Designation).Select(y => y.HourlyRate).FirstOrDefaultAsync(); Double hours = (End.ToLocalTime() - Start.ToLocalTime()).TotalHours; var proj = await _context.Projects.FindAsync(projectId); proj.Cost = proj.Cost + (rate * hours); proj.FinalizedTasks = proj.FinalizedTasks + 1; var collections = _context.PreSalescollection.Where(x => x.ProjecstID == projectId).ToList(); double cumilativeCollectionValue = collections[0].value; try { for (int i = 0; i < collections.Count; i++) { if (cumilativeCollectionValue < proj.Cost && cumilativeCollectionValue + collections[i + 1].value < proj.Cost) { Utility.EmailSender.BudgetRemainder(); break; } if (i != 0) { cumilativeCollectionValue = cumilativeCollectionValue + collections[i].value; } } } catch (Exception) { throw; } _context.Entry(proj).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
//edit task part public async Task <bool> EditTasks(PreTaskModel task) { var tas = await _context.PreSalesTasks.FindAsync(task.Id); tas.Description = task.Description; tas.Number = task.Number; tas.Duration = task.Duration; tas.StartDate = task.StartDate; tas.EndDate = task.EndDate; tas.Priority = task.Priority; tas.Assignee = task.Assignee; tas.ProjectsID = task.ProjectsID; _context.Entry(tas).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
public async Task <bool> EditBudgets(BudgetModel budget) { var bug = await _context.PreSalesBudget.FindAsync(budget.Id); bug.Actual = budget.Actual; bug.LbHou = budget.LbHou; bug.LbRate = budget.LbRate; bug.MtUnit = budget.MtUnit; bug.MtunitPr = budget.MtunitPr; bug.Under = budget.Under; bug.cost = budget.cost; bug.BudgetCost = budget.BudgetCost; bug.ProjectsID = budget.ProjectsID; _context.Entry(bug).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }
// new part public async Task <bool> EditProjects(ProjectModel project) { var pro = await _context.PreSalesProjects.FindAsync(project.ID); pro.Title = project.Title; pro.Description = project.Description; pro.ProjectType = project.ProjectType; pro.startDate = project.startDate; pro.endDate = project.EndDate; pro.value = project.value; pro.ProjectBudget = project.ProjectBudget; project.projectManager = project.projectManager; //pro.Customers = project.Customers; _context.Entry(pro).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); }