public IQueryable GetTree(int?id, string culture, int companyId) { var menus = (from m in context.Menus where m.ParentId == id && m.CompanyId == companyId join m2 in context.Menus on m.Id equals m2.ParentId into g2 from m2 in g2.DefaultIfEmpty() join t in context.NamesTbl on m.Name equals t.Name into g from t in g.Where(a => a.Culture == culture).DefaultIfEmpty() select new { Id = m.Id, CompanyId = m.CompanyId, Name = HrContext.TrlsName(m.Name, culture), MenuLevel = m.NodeType, Order = m.Order, Title = (t.Title == null ? m.Name : t.Title), ParentId = m.ParentId, Sort = m.Sort, Url = m.Url, Icon = m.Icon, hasChildren = m2 != null }).Distinct() .OrderBy(r => r.Sort); return(menus); }
//ReadConsumeCustody public IQueryable <CustodyViewModel> ReadConsumeCustody(byte Range, DateTime?Start, DateTime?End, string culture, int CompanyId) { //10- All, 0-Custom if (Range != 10 && Range != 0) { RequestRangeFilter(Range, CompanyId, out Start, out End); } var query = from c in context.Custody where (c.CompanyId == CompanyId && c.CustodyCat.Disposal) join ec in context.EmpCustodies on c.Id equals ec.CustodyId into g from ec in g.DefaultIfEmpty() group ec by new { Id = c.Id, Name = c.Name, PurchaseDate = c.PurchaseDate, PurchaseAmount = c.PurchaseAmount, Qty = c.Qty, Description = c.Description, CustodyCat = c.CustodyCat.Name, CurrRate = c.CurrencyRate } into g select new CustodyViewModel { Id = g.Key.Id, Name = g.Key.Name, PurchaseDate = g.Key.PurchaseDate, PurchaseAmount = g.Key.PurchaseAmount, Qty = g.Key.Qty, CurrencyRate = g.Key.CurrRate, CustodyCatId = HrContext.TrlsName(g.Key.CustodyCat, culture), RestQty = g.Key.Qty - (g.Sum(x => x.Qty) == null ? 0 : g.Sum(x => x.Qty)), Description = g.Key.Description }; if (Range != 10) { query = query.Where(c => Start <= c.PurchaseDate && End >= c.PurchaseDate); } return(query.Where(a => a.RestQty > 0)); }
//read Borrow Document with Employee public IEnumerable <EmpDocBorrowViewModel> ReadDocBorrow(byte Range, DateTime?Start, DateTime?End, int CompanyId, string culture) { //10- All, 0-Custom if (Range != 10 && Range != 0) { RequestRangeFilter(Range, CompanyId, out Start, out End); } var query = (from d in context.EmpDocBorrow where (d.CompanyId == CompanyId && d.delvryDate == null) join p in context.People on d.EmpId equals p.Id select new EmpDocBorrowViewModel { Id = d.Id, CompanyId = d.CompanyId, Employee = HrContext.TrlsName(p.Title + " " + p.FirstName + " " + p.Familyname, culture), EmpId = d.EmpId, Purpose = d.Purpose, Notes = d.Notes, RecvDate = d.RecvDate, Site = d.Site, ExpdelvryDate = d.ExpdelvryDate, AttUrl = HrContext.GetDoc("BorrowPapers", d.Id), Document = context.DocBorrowList.Where(a => a.DocBorrowId == d.Id).Select(s => s.Doc.Name).ToList() }).ToList(); if (Range != 10) { query = query.Where(c => Start <= c.RecvDate && End >= c.RecvDate).ToList(); } return(query); }
public IQueryable <CustodyViewModel> ReadCustody(byte Range, DateTime?Start, DateTime?End, string culture, int CompanyId) { //10- All, 0-Custom if (Range != 10 && Range != 0) { RequestRangeFilter(Range, CompanyId, out Start, out End); } var custody = from c in context.Custody where (c.CompanyId == CompanyId && !c.CustodyCat.Disposal && !c.InUse) select new CustodyViewModel { Id = c.Id, Code = c.Code, Name = c.Name, SerialNo = c.SerialNo, CompanyId = c.CompanyId, CustodyCatId = HrContext.TrlsName(c.CustodyCat.Name, culture), PurchaseDate = c.PurchaseDate, PurchaseAmount = c.PurchaseAmount, Status = c.Status, InUse = c.InUse, Freeze = c.Freeze, Description = c.Description, Qty = c.Qty }; if (Range != 10) { custody = custody.Where(c => Start <= c.PurchaseDate && End >= c.PurchaseDate); } return(custody); }
public IQueryable <CustodyViewModel> ReadEmpCustody(int CompanyId, string culture) { var result = (from c in context.Custody where (c.CompanyId == CompanyId && c.InUse == true) join Emp in context.EmpCustodies on c.Id equals Emp.CustodyId where Emp.delvryDate == null join p in context.People on Emp.EmpId equals p.Id join l in context.Sites on Emp.BranchId equals l.Id into j from l in j.DefaultIfEmpty() select new CustodyViewModel { Id = c.Id, EmpCustodyId = Emp.Id, Code = c.Code, Name = c.Name, SerialNo = c.SerialNo, CompanyId = c.CompanyId, CustodyCatId = HrContext.TrlsName(c.CustodyCat.Name, culture), PurchaseAmount = c.PurchaseAmount, Status = c.Status, InUse = c.InUse, Employee = HrContext.TrlsName(p.Title + " " + p.FirstName + " " + p.Familyname, culture), Branch = HrContext.TrlsName(l.Name, culture), EmpId = Emp.EmpId, Description = c.Description, Qty = Emp.Qty, RecvDate = Emp.RecvDate, PurchaseDate = c.PurchaseDate, AttUrl = HrContext.GetDoc("RecieveCustody", Emp.Id), Filename = context.CompanyDocsView.Where(a => a.Source == "RecieveCustody" && a.SourceId == Emp.Id).Select(c => c.name).FirstOrDefault() }); return(result); }
public DocTypeFormViewModel ReadDocType(int Id, string culture) { var query = (from d in context.DocTypes where d.Id == Id select new DocTypeFormViewModel { Id = d.Id, EndDate = d.EndDate, IsLocal = d.IsLocal, Name = d.Name, RequiredOpt = d.RequiredOpt, StartDate = d.StartDate, DocumenType = d.DocumenType, HasExpiryDate = d.HasExpiryDate, AccessLevel = d.AccessLevel, LocalName = HrContext.TrlsName(d.Name, culture), IJobs = d.Jobs.Select(a => a.Id), INationalities = d.Nationalities.Select(a => a.Id), ModifiedTime = d.ModifiedTime, ModifiedUser = d.ModifiedUser, CreatedUser = d.CreatedUser, CreatedTime = d.CreatedTime, Gender = d.Gender, NotifyDays = d.NotifyDays }).FirstOrDefault(); return(query); }
public ComplaintRequestViewModel GetRequest(int requestId, string culture) { ComplaintRequestViewModel Request = (from req in context.ComplainRequests where req.Id == requestId join p in context.People on req.EmpId equals p.Id select new ComplaintRequestViewModel() { Id = req.Id, RequestDate = req.RequestDate, EmpId = req.EmpId, Employee = HrContext.TrlsName(p.Title + " " + p.FirstName + " " + p.Familyname, culture), ApprovalStatus = req.ApprovalStatus, RejectReason = req.RejectReason, RejectDesc = req.RejectDesc, CancelReason = req.CancelReason, CancelDesc = req.CancelDesc, Attachments = HrContext.GetAttachments("ComplaintRequest", req.Id), CreatedTime = req.CreatedTime, CreatedUser = req.CreatedUser, ModifiedTime = req.ModifiedTime, ModifiedUser = req.ModifiedUser, ComplainType = req.ComplainType, Description = req.Description, Against = req.Against }).FirstOrDefault(); return(Request); }
public IQueryable <EmpChkListViewModel> GetEmpCheckLists(string culture, int companyId) { var EmpList = from el in context.EmpChkLists where el.CompanyId == companyId join p in context.People on el.EmpId equals p.Id into g from p in g.DefaultIfEmpty() select new EmpChkListViewModel { Id = el.Id, EmpId = el.EmpId, ListEndDate = el.ListEndDate, ListStartDate = el.ListStartDate, PicUrl = HrContext.GetDoc("EmployeePic", p.Id), Gender = p.Gender, ListType = el.ListType, Name = el.Name, Employee = p != null?HrContext.TrlsName(p.Title + " " + p.FirstName + " " + p.Familyname, culture) : "", Status = el.Status, CreatedUser = el.CreatedUser, ManagerId = el.ManagerId, Count = context.EmpTasks.Where(a => a.EmpListId == el.Id).Count(), PrograssBar = context.EmpTasks.Where(a => a.EmpListId == el.Id && a.Status == 2).Count() }; return(EmpList); }
public CheckListFormViewModel ReadCheckList(int id, string culture) { var Job = (from J in context.CheckLists where J.Id == id select new CheckListFormViewModel { Id = J.Id, Name = J.Name, IsLocal = J.IsLocal, LocalName = HrContext.TrlsName(J.Name, culture), StartDate = J.StartDate, EndDate = J.EndDate, Duration = J.Duration, CompanyId = J.CompanyId, Default = J.Default, Description = J.Description, ListType = J.ListType, ModifiedTime = J.ModifiedTime, ModifiedUser = J.ModifiedUser, CreatedTime = J.CreatedTime, CreatedUser = J.CreatedUser, }).FirstOrDefault(); return(Job); }
public IQueryable <EmpTasksViewModel> ReadEmployeeTasksGrid(int empId, string culture) { var tasks = context.EmpTasks.Where(t => t.EmpId == empId && t.Status != 0).OrderBy(t => new { t.Status, t.Priority }).Select(t => new EmpTasksViewModel { Id = t.Id, EmpList = HrContext.TrlsName(t.EmpChklist.Name, culture), EmpListId = t.EmpListId, Manager = HrContext.TrlsName(t.Manager.Title + " " + t.Manager.FirstName + " " + t.Manager.Familyname, culture), Description = t.Description, Priority = t.Priority, Status = t.Status, TaskCategory = HrContext.GetLookUpCode("EmpTaskCat", t.TaskCat.Value, culture), TaskNo = t.TaskNo, AssignedTime = t.AssignedTime, StartTime = t.StartTime, EndTime = t.EndTime, Duration = t.Duration, ExpectDur = t.ExpectDur, Unit = t.Unit, Required = t.Required, SubPeriodId = t.SubPeriodId, SubPeriod = t.SubPeriod.Name }); return(tasks); }
public EmpTasksViewModel GetEmployeeTask(int Id, string culture) { EmpTasksViewModel task = context.EmpTasks.Where(t => t.Id == Id) .Select(t => new EmpTasksViewModel { Id = t.Id, EmpList = t.EmpChklist.Name, Manager = HrContext.TrlsName(t.Manager.Title + " " + t.Manager.FirstName + " " + t.Manager.Familyname, culture), Description = t.Description, Priority = t.Priority, Status = t.Status, TaskCategory = HrContext.GetLookUpCode("EmpTaskCat", t.TaskCat.Value, culture), TaskNo = t.TaskNo, AssignedTime = t.AssignedTime, Attachments = HrContext.GetAttachments("EmpTasksForm", t.Id), StartTime = t.StartTime, EndTime = t.EndTime, Duration = t.Duration, EmpListId = t.EmpListId, ExpectDur = t.ExpectDur, Unit = t.Unit, Required = t.Required, Employee = HrContext.TrlsName(t.EmpChklist.Employee.Title + " " + t.EmpChklist.Employee.FirstName + " " + t.EmpChklist.Employee.Familyname, culture), }).FirstOrDefault(); return(task); }
public IQueryable <NotifiyLetterViewModel> GetMyLetters(int CompanyId, string Language, int EmpId) { DateTime Today = DateTime.Today.Date; var query = (from n in context.NotifyLetters where n.EmpId == EmpId join a in context.Assignments on n.EmpId equals a.EmpId into g1 from a in g1.Where(x => x.CompanyId == n.CompanyId && x.AssignDate <= Today && x.EndDate >= Today).DefaultIfEmpty() select new NotifiyLetterViewModel { CompanyId = n.CompanyId, Department = HrContext.TrlsName(a.Department.Name, Language), Description = n.Description, Employee = HrContext.TrlsName(n.Emp.Title + " " + n.Emp.FirstName + " " + n.Emp.Familyname, Language), EventDate = n.EventDate, Id = n.Id, Job = HrContext.TrlsName(a.Job.Name, Language), NotifyDate = n.NotifyDate, NotifySource = n.NotifySource, Readdatetime = n.ReadTime, read = n.read, Sent = n.Sent, EmpId = n.EmpId }).OrderByDescending(s => s.NotifyDate); //.ThenByDescending(ss => ss.NotifyDate); return(query.AsQueryable()); }
public JobViewModel ReadJob(int id, string culture) { var Job = (from J in context.Jobs where J.Id == id select new JobViewModel { Id = J.Id, Code = J.Code, Name = J.Name, IsLocal = J.IsLocal, LName = HrContext.TrlsName(J.Name, culture), DefaultGradeId = J.DefaultGradeId, IJobClasses = J.JobClasses.Select(a => a.Id), StartDate = J.StartDate, EndDate = J.EndDate, NameInInsurance = J.NameInInsurance, PlanCount = J.PlanCount, PlanTurnOverRate = J.PlanTurnOverRate, ProbationPeriod = J.ProbationPeriod, PrimaryRole = J.PrimaryRole, StartTime = J.StartTime, EndTime = J.EndTime, Frequency = J.Frequency, WorkHours = J.WorkHours, ModifiedTime = J.ModifiedTime, ModifiedUser = J.ModifiedUser, CreatedTime = J.CreatedTime, CreatedUser = J.CreatedUser, ContractTempl = J.ContractTempl, CompanyId = J.CompanyId }).FirstOrDefault(); return(Job); }
public MenuViewModel GetMenu(int Id, string culture) { var menu = (from m in context.Menus where m.Id == Id select new MenuViewModel { Id = m.Id, ColumnList = m.ColumnList, CompanyId = m.CompanyId, Icon = m.Icon, NodeType = m.NodeType, MenuName = m.Name, Order = m.Order, ParentId = m.ParentId, ParentName = HrContext.TrlsName(m.Parent.Name, culture), Sort = m.Sort, Url = m.Url, WhereClause = m.WhereClause, Title = HrContext.TrlsName(m.Name + m.Version, culture), IsVisible = m.IsVisible, SSMenu = m.SSMenu, Version = m.Version, Sequence = m.Sequence, CreatedTime = m.CreatedTime, ModifiedTime = m.ModifiedTime, CreatedUser = m.CreatedUser, ModifiedUser = m.ModifiedUser, IFunctions = context.MenuFunctions.Where(a => a.MenuId == m.Id).Select(c => c.FunctionId).ToList() }).FirstOrDefault(); return(menu); }
public IEnumerable <EmployeeTrainPathViewModel> TrainPathProgress(int id, string culture) { var q = context.TrainPath.Where(a => a.Id == id).Select(a => new { c = a.Courses.Select(b => b.Id), id = a.Id }).FirstOrDefault(); if (q != null) { var Emp = context.PeopleTraining. Where(a => q.c.Contains(a.CourseId) && a.Status == 2).GroupBy(a => new { person = a.EmpId, Emp = a.Person }). Select(a => new EmployeeTrainPathViewModel { EmpId = a.Key.person, Id = q.id, Percent = a.Count() * 100 / q.c.Count(), Employee = HrContext.TrlsName(a.Key.Emp.Title + " " + a.Key.Emp.FirstName + " " + a.Key.Emp.Familyname, culture), CourseName = a.Select(j => j.Course.Name).ToList(), CourseIds = a.Select(j => j.Course.Id).ToList(), } ).ToList(); return(Emp); } else { return(null); } }
public IQueryable <CustodyViewModel> GetEmpCustody(int EmpId, int CompanyId, string culture) { var result = from c in context.Custody where (c.CompanyId == CompanyId) join Emp in context.EmpCustodies on c.Id equals Emp.CustodyId where Emp.delvryDate == null && Emp.EmpId == EmpId join p in context.People on Emp.EmpId equals p.Id join l in context.Sites on Emp.BranchId equals l.Id into j from l in j.DefaultIfEmpty() select new CustodyViewModel { Id = c.Id, Code = c.Code, Name = c.Name, SerialNo = c.SerialNo, CustodyCatId = HrContext.TrlsName(c.CustodyCat.Name, culture), Disposal = c.CustodyCat.Disposal, Status = c.Status, InUse = c.InUse, Description = c.Description, PurchaseDate = c.PurchaseDate, PurchaseAmount = c.PurchaseAmount, Employee = HrContext.TrlsName(p.Title + " " + p.FirstName + " " + p.Familyname, culture), Branch = HrContext.TrlsName(l.Name, culture), EmpId = Emp.EmpId, Qty = Emp.Qty }; return(result); }
public Dictionary <string, string> ReadMailEmpTerm(string Language, int Id) { DateTime Today = DateTime.Today.Date; var query = (from r in context.Terminations where r.Id == Id join a in context.Assignments on r.EmpId equals a.EmpId into g from a in g.Where(x => x.CompanyId == r.CompanyId && x.AssignDate <= Today && x.EndDate >= Today).DefaultIfEmpty() join m in context.People on a.ManagerId equals m.Id into g1 from m in g1.DefaultIfEmpty() select new { EmployeeName = HrContext.TrlsName(r.Employee.Title + " " + r.Employee.FirstName + " " + r.Employee.Familyname, Language), Job = HrContext.TrlsName(a.Job.Name, Language), PlannedEndDate = r.PlanedDate.Value.ToString(), RequestDate = r.RequestDate.ToString(), Department = HrContext.TrlsName(a.Department.Name, Language), DirectManager = HrContext.TrlsName(m.Title + " " + m.FirstName + " " + m.Familyname, Language), }).FirstOrDefault(); Dictionary <string, string> dic = new Dictionary <string, string>(); if (query != null) { var ObjProps = query.GetType().GetProperties(); for (int i = 0; i < ObjProps.Length; i++) { var p = ObjProps[i].GetValue(query); dic.Add(ObjProps[i].Name, p != null ? p.ToString() : " "); } } return(dic); }
public IQueryable <MedicalIndexViewModel> GetApprovedMedicalReq(int companyId, string culture) { return(from l in context.BenefitRequests where l.CompanyId == companyId && l.ApprovalStatus == 6 join n in context.BenefitServs on l.ServiceId equals n.Id join prov in context.Providers on l.ProviderId equals prov.Id join p in context.People on l.EmpId equals p.Id join wft in context.WF_TRANS on new { p1 = "Medical", p2 = l.CompanyId, p3 = l.Id } equals new { p1 = wft.Source, p2 = wft.SourceId, p3 = wft.DocumentId } into g from wft in g.DefaultIfEmpty() select new MedicalIndexViewModel { Id = l.Id, RequestDate = l.RequestDate, Employee = HrContext.TrlsName(p.Title + " " + p.FirstName + " " + p.Familyname, culture), ApprovalStatus = l.ApprovalStatus, CompanyId = l.CompanyId, EmpId = l.EmpId, RoleId = wft.RoleId.ToString(), DeptId = wft.DeptId, PositionId = wft.PositionId, AuthBranch = wft.AuthBranch, AuthDept = wft.AuthDept, AuthEmp = wft.AuthEmp, AuthPosition = wft.AuthPosition, BranchId = wft.BranchId, Attachment = HrContext.GetDoc("EmployeePic", p.Id), Gender = p.Gender, Service = n.Name, Provider = prov.Name }); }
public IQueryable <MenuViewModel> ReadMenu(int companyId, string culture) { var menus = from m1 in context.Menus where m1.CompanyId == companyId join m2 in context.Menus on m1.ParentId equals m2.Id into g1 join t in context.NamesTbl on m1.Name equals t.Name into g2 from t in g2.Where(gg => gg.Culture == culture).DefaultIfEmpty() from m2 in g1.DefaultIfEmpty() join t2 in context.NamesTbl on m2.Name equals t2.Name into g3 from t2 in g3.Where(ggg => ggg.Culture == culture).DefaultIfEmpty() orderby m1.Sort select new MenuViewModel { Id = m1.Id, CompanyId = m1.CompanyId, MenuName = m1.Name, Version = m1.Version, Title = HrContext.TrlsName(m1.Name + m1.Version, culture), NodeType = m1.NodeType, Order = m1.Order, ParentId = m1.ParentId, ParentName = (t2.Title == null ? (m2.Name == null ? "" : m2.Name) : t2.Title), Sort = m1.Sort, Url = m1.Url, Icon = m1.Icon, ColumnList = m1.ColumnList, WhereClause = m1.WhereClause }; return(menus); }
public IQueryable <SiteViewModel> ReadSites(string culture, int CompanyId) { var Sites = from l in context.Sites join code in context.LookUpCodes on new { p1 = "SiteType", p2 = l.SiteType } equals new { p1 = code.CodeName, p2 = code.CodeId } join t in context.LookUpTitles on new { code.CodeName, code.CodeId } equals new { t.CodeName, t.CodeId } into g1 from t in g1.DefaultIfEmpty() join d in context.Districts on l.DistrictId equals d.Id into g2 from d in g2.DefaultIfEmpty() join city in context.Cities on l.CityId equals city.Id into g3 from city in g3.DefaultIfEmpty() join co in context.Countries on l.CountryId equals co.Id into g4 from co in g4.DefaultIfEmpty() select new SiteViewModel { Id = l.Id, Code = l.Code, Name = l.Name, LocalName = HrContext.TrlsName(l.Name, culture), TimeZone = l.TimeZone, Latitude = l.Latitude, Longitude = l.Longitude, Address = l.Address1, City = culture.Substring(0, 2) == "ar" ? city.NameAr : code.Name, District = culture.Substring(0, 2) == "ar" ? d.NameAr : d.Name, Country = culture.Substring(0, 2) == "ar" ? co.NameAr : d.Name, SiteType = (t == null ? code.Name : t.Title), SiteToEmployees = context.SiteToEmployees.Where(a => a.SiteId == l.Id).Select(s => HrContext.TrlsName(s.Employee.Title + " " + s.Employee.FirstName + " " + s.Employee.Familyname, culture)).ToList(), ContactPerson = l.ContactPerson, Email = l.Email, Mobile = l.Telephone }; return(Sites); }
public AddSiteViewModel ReadSite(int Id, int read, string culture) { var site = (from l in context.Sites where l.Id == Id select new AddSiteViewModel { Id = l.Id, Code = l.Code, Name = l.Name, TimeZone = l.TimeZone, Description = l.Description, EndDate = l.EndDate, StartDate = l.StartDate, LName = HrContext.TrlsName(l.Name, culture), Longitude = l.Longitude, Latitude = l.Latitude, CityId = l.CityId, Address1 = l.Address1, DistrictId = l.DistrictId, CountryId = l.CountryId, PostalCode = l.PostalCode, ContactPerson = l.ContactPerson, Telephone = l.Telephone, Email = l.Email, SiteToEmployees = context.SiteToEmployees.Where(a => a.SiteId == Id).Select(s => s.EmpId).ToList(), SiteToEmployeesNames = context.SiteToEmployees.Where(a => a.SiteId == l.Id).Select(s => HrContext.TrlsName(s.Employee.Title + " " + s.Employee.FirstName + " " + s.Employee.Familyname, culture)).ToList(), CreatedTime = l.CreatedTime, ModifiedTime = l.ModifiedTime, CreatedUser = l.CreatedUser, ModifiedUser = l.ModifiedUser, SiteType = l.SiteType }).FirstOrDefault(); return(site); }
public AddBranchViewModel ReadBranch(int id, string culture) { var branch = (from l in context.Branches where l.Id == id select new AddBranchViewModel { Id = l.Id, Code = l.Code, Name = l.Name, TimeZone = l.TimeZone, LName = HrContext.TrlsName(l.Name, culture), Longitude = l.Longitude, Latitude = l.Latitude, Address1 = l.Address1, CityId = l.CityId, CountryId = l.CountryId, DistrictId = l.DistrictId, Telephone = l.Telephone, CreatedTime = l.CreatedTime, ModifiedTime = l.ModifiedTime, CreatedUser = l.CreatedUser, ModifiedUser = l.ModifiedUser }).FirstOrDefault(); return(branch); }
// Get the employee with Dept manger role only // Done By fatma public IQueryable <FormList> GetActiveMangers(int companyId, string culture) { var today = DateTime.Today.Date; //Get Departments managers var query1 = (from a in context.Assignments where a.CompanyId == companyId && a.AssignDate <= today && a.EndDate >= today && a.IsDepManager == true select new FormList { id = a.EmpId, name = HrContext.TrlsName(a.Employee.Title + " " + a.Employee.FirstName + " " + a.Employee.Familyname, culture), PicUrl = HrContext.GetDoc("EmployeePic", a.EmpId), Gender = a.Employee.Gender, Icon = HrContext.GetEmpStatus(a.Employee.Id) }); var query2 = (from a in context.Assignments where a.CompanyId == companyId && a.AssignDate <= today && a.EndDate >= today join p in context.People on a.ManagerId equals p.Id select new FormList { id = p.Id, name = HrContext.TrlsName(p.Title + " " + p.FirstName + " " + p.Familyname, culture), PicUrl = HrContext.GetDoc("EmployeePic", p.Id), Gender = p.Gender, Icon = HrContext.GetEmpStatus(p.Id) }).Distinct(); var query3 = query1.Union(query2); return(query3); }
public CompanyStructureViewModel GetStructure(int?Id, string culture) { var Compastruc = (from c in context.CompanyStructures where c.Id == Id select new CompanyStructureViewModel { Id = c.Id, Code = c.Code, ModifiedTime = c.ModifiedTime, ModifiedUser = c.ModifiedUser, Name = c.Name, ParentId = c.ParentId, PlannedCount = c.PlannedCount, ParentName = c.Parent.Name, NodeType = c.NodeType, StartDate = c.StartDate, EndDate = c.EndDate, Icon = c.Icon, IsVisible = c.IsVisible, ColorName = c.ColorName != null? c.ColorName:"", CreatedTime = c.CreatedTime, CreatedUser = c.CreatedUser, LocalName = HrContext.TrlsName(c.Name, culture), }).FirstOrDefault(); return(Compastruc); }
public IQueryable <MeetingAgendaViewModel> GetAgenda(int Id, string culture) { var query = (from m in context.MeetScheduals where m.MeetingId == Id join p in context.People on m.EmpId equals p.Id into j from x in j.DefaultIfEmpty() select new MeetingAgendaViewModel { Id = m.Id, StartTime = m.StartTime.ToString(), EndTime = m.EndTime.ToString(), Description = m.Description, EmpId = m.EmpId, EmpName = HrContext.TrlsName(x.Title + " " + x.FirstName + " " + x.Familyname, culture), }).ToList().Select(l => new MeetingAgendaViewModel { Id = l.Id, EmpId = l.EmpId, StartTime = Convert.ToDateTime(l.StartTime).ToString("hh:mm tt"), EndTime = Convert.ToDateTime(l.EndTime).ToString("hh:mm tt"), Description = l.Description, Time = (Convert.ToDateTime(l.EndTime) - Convert.ToDateTime(l.StartTime)).ToString(@"hh\:mm") }); return(query.AsQueryable()); }
public string DeleteFlexColumns(FlexColumn model, string culture) { string msg = "OK"; if (model == null) { return(msg); } // Check before delete var columnNames = model.ColumnName; var page = model.PageId; var related = (from fc in context.FlexColumns where fc.PageId == page && columnNames.Contains(fc.ColumnName) join fd in context.FlexData on new { fc.PageId, fc.ColumnName } equals new { fd.PageId, fd.ColumnName } join pd in context.PageDiv on fc.PageId equals pd.Id join m in context.Menus on pd.MenuId equals m.Id select new { name = fc.ColumnName, page = HrContext.TrlsName(m.Name + m.Sequence, culture) }).FirstOrDefault(); if (related != null) { msg = MsgUtils.Instance.Trls(culture, "DeleteRelatedRecord").Replace("{0}", related.page) + ": " + related.name; return(msg); } var Id = model.Id; var titles = context.ColumnTitles.ToList(); var DeleteObj = model; context.FlexColumns.Attach(DeleteObj); context.Entry(DeleteObj).State = EntityState.Deleted; var DeleteTitles = titles.Where(a => a.ColumnName == model.ColumnName).ToList(); RemoveRange(DeleteTitles); return(msg); }
public CompanyFormViewModel ReadCompany(int id, string culture) { var query = (from c in context.Companies where c.Id == id select new CompanyFormViewModel { Id = c.Id, CommFileNo = c.CommFileNo, Consolidation = c.Consolidation, CountryId = c.CountryId, Email = c.Email, InsuranceNo = c.InsuranceNo, Language = c.Language, Name = c.Name, LocalName = HrContext.TrlsName(c.Name, culture), Memo = c.Memo, Purpose = c.Purpose, TaxCardNo = c.TaxCardNo, WebSite = c.WebSite, TaxAuthority = c.TaxAuthority, SearchName = c.SearchName, CreatedTime = c.CreatedTime, CreatedUser = c.CreatedUser, ModifiedTime = c.ModifiedTime, ModifiedUser = c.ModifiedUser, Attachments = HrContext.GetAttachments("Company", c.Id), LegalForm = c.LegalForm, Office = c.Office, Region = c.Region, Responsible = c.Responsible }).FirstOrDefault(); return(query); }
public List <StreamID_DocTypeFormViewModel> GetDocsViews_Uploaded(string Source, int SourceId, string CodeName /*,int SysCodeId*/, string Lang) { try { var BasicQuery = GetDocsViews_Queryable(Source, SourceId); var DocsViews = (from c in BasicQuery join d in context.DocTypes on c.TypeId equals d.Id //join l in context.LookUpUserCodes on d.DocumenType equals l.SysCodeId//new { p1 = d.Name, p2 = d.DocumenType } equals new { p1 = l.CodeName, p2 = l.CodeId } // where c.Source == Source /*&& l.CodeName == CodeName *///&& l.SysCodeId == SysCodeId select new StreamID_DocTypeFormViewModel { Stream_Id = c.stream_id, DocTypeFormViewModel = new DocTypeFormViewModel { Id = d.Id, Name = HrContext.TrlsName(d.Name, Lang), RequiredOpt = d.RequiredOpt, HasExpiryDate = d.HasExpiryDate } }).ToList(); return(DocsViews); } catch { return(new List <StreamID_DocTypeFormViewModel>()); } }
public IEnumerable GetobjectName(int companyId, string culture) { var query = context.PageDiv.Where(w => w.CompanyId == companyId && w.HasCustCols == true).Select(s => new LabelDDListViewModel { value = s.Id, title = s.ObjectName, text = HrContext.TrlsName(s.Menu.Name + s.Version, culture) }).ToList(); return(query); }
public IEnumerable <TrainCourseViewModel> GetMissCourses(int id, int [] courses, string Culture) { var q = context.TrainPath.Where(a => a.Id == id).Select(a => a.Courses.Where(b => !courses.Contains(b.Id)).Select(b => b.Id)).FirstOrDefault(); var query = context.TrainCourses.Where(c => q.Contains(c.Id)).Select(c => new TrainCourseViewModel { Name = HrContext.TrlsName(c.Name, Culture) }).ToList(); return(query); }