/// <summary> /// Hàm sửa thông tin công việc /// Nguyễn Đình Hoàng - 20173143 /// </summary> /// <param name="pro"></param> /// <returns></returns> public bool EditWork(WorkEditView work) { var old_pro = dbContext.Works.FirstOrDefault(x => x.WorkId == work.WorkId); if (old_pro != null) { old_pro.WorkName = work.WorkName; old_pro.WorkDescription = work.WorkDescription; dbContext.SaveChanges(); return(true); } return(false); }
/// <summary> /// Hàm lấy thông tin công việc bằng id /// Nguyễn Đình Hoàng - 20173143 /// </summary> /// <param name="projectId"></param> /// <returns></returns> public WorkEditView GetWorkById(Guid workId) { var pro_db = dbContext.Works.FirstOrDefault(x => x.WorkId == workId); var pro = new WorkEditView { WorkId = pro_db.WorkId, WorkName = pro_db.WorkName, WorkDescription = pro_db.WorkDescription, WorkPhases = dbContext.Phases.Where(x => x.WorkId == workId).OrderBy(x => x.OrderNumber).ToList() }; foreach (Phase phase in pro.WorkPhases) { if (phase.EmployeeId != null) { var emp = dbContext.Users.FirstOrDefault(x => x.Id == phase.EmployeeId.ToString()); phase.DisplayName = emp.FullName + " " + emp.EmployeeCode; } } return(pro); }