public int UpdatePersonStatus(int EmpID, List <int> RequiredDocTypeIDsList, int?DocTypeID_AddEditeMode, int?DocTypeID_DeleteMode, out int OldEmpStatus) { int CurrentEmpStatus = 0; OldEmpStatus = 0; try { bool IsAllReqPapersUploaded = hrUnitOfWork.CompanyRepository.IsAllRequiredPapersUploaded(Constants.Sources.People, EmpID, RequiredDocTypeIDsList, DocTypeID_AddEditeMode, DocTypeID_DeleteMode); Person per = hrUnitOfWork.Repository <Person>().SingleOrDefault <Person>(a => a.Id == EmpID); if (per != null) { OldEmpStatus = Convert.ToInt32(per.Status); if (IsAllReqPapersUploaded) { if (per.Status < PersonStatus.Assignment) { per.Status = PersonStatus.Assignment; } } else { if (per.Status == PersonStatus.Assignment) { per.Status = PersonStatus.Papers; } } CurrentEmpStatus = Convert.ToInt32(per.Status); } } catch { } return(CurrentEmpStatus); }
public ActionResult DeleteCareerPath(int Id) { var datasource = new DataSource <CareerPathViewModel>(); var Obj = _hrUnitOfWork.Repository <CareerPath>().FirstOrDefault(k => k.Id == Id); AutoMapper(new Models.AutoMapperParm { Source = Obj, ObjectName = "CareerPaths", Transtype = TransType.Delete }); _hrUnitOfWork.JobRepository.Remove(Obj); datasource.Errors = SaveChanges(Language); datasource.Total = 1; if (datasource.Errors.Count > 0) { return(Json(datasource)); } else { return(Json("OK")); } }
public IHttpActionResult GetMedicalRequest(int id = 0) { var Medical = _hrUnitOfWork.MedicalRepository.ReadMedical(id); IEnumerable BeneficiaryId = null; IEnumerable Services = null; //if (User.Identity.IsSelfServiceUser()) //{ int EmpId = User.Identity.GetEmpId(); BeneficiaryId = _hrUnitOfWork.Repository <EmpRelative>().Where(a => a.EmpId == 1034).Select(p => new { id = p.Id, name = p.Name }).ToList(); //} if (Medical != null) { BeneficiaryId = _hrUnitOfWork.Repository <EmpRelative>().Where(a => a.EmpId == Medical.EmpId).Select(p => new { id = p.Id, name = p.Name }).ToList(); Services = _hrUnitOfWork.MedicalRepository.GetAllservice(Medical.EmpId, Medical.BenefitId, Medical.BeneficiaryId); } var Providers = _hrUnitOfWork.MedicalRepository.GetAllProvider(); var Currency = _hrUnitOfWork.LookUpRepository.GetCurrencyCode(); var BenefitClass = _hrUnitOfWork.LookUpRepository.GetLookUpCodes("BenefitClass", User.Identity.GetLanguage()).Select(a => new { id = a.CodeId, name = a.Title }); // string culture = User.Identity.GetLanguage(); //List<string> columns = _hrUnitOfWork.LeaveRepository.GetAutoCompleteColumns("MedicalRequestsForm", User.Identity.GetDefaultCompany(), Version); //if (columns.FirstOrDefault(fc => fc == "EmpId") == null) // var Employees = _hrUnitOfWork.EmployeeRepository.GetActiveEmployees(User.Identity.GetLanguage(), Medical != null ? Medical.EmpId : 0, User.Identity.GetDefaultCompany()).Select(a => new { id = a.Id, name = a.Employee, PicUrl = a.PicUrl, Icon = a.EmpStatus }).ToList(); if (id == 0) { Medical = new MedicalRequestViewModel(); } return(Ok(new { request = Medical, Currency = Currency, Providers = Providers, BeneficiaryId = BeneficiaryId, Services = Services, BenefitClass = BenefitClass })); }
public IHttpActionResult GetEmpiscplin(int MenuId) { var Discplin = _hrUnitOfWork.Repository <Discipline>().Select(a => new { text = a.Name, value = a.Id }).ToList(); var query = _hrUnitOfWork.DisciplineRepository.ReadEmpDiscipline(User.Identity.GetLanguage(), User.Identity.GetDefaultCompany()); IEnumerable <EmpDisciplineViewModel> queryResult = null; string whecls = GetWhereClause(MenuId); if (whecls.Length > 0) { try { query = query.Where(whecls); queryResult = query.ToList(); foreach (var item in queryResult) { item.Discplin = Discplin.Where(a => a.value == item.DiscplinId).Select(a => a.text).FirstOrDefault(); } } catch (Exception ex) { //TempData["Error"] = ex.Message; Models.Utils.LogError(ex.Message); return(Ok("")); } } return(Ok(queryResult)); }
public ActionResult SecondPage() { ViewBag.SalaryItem = _hrUnitOfWork.Repository <SalaryItem>().Where(a => (a.IsSalaryItem) && (!a.IsLocal || a.CompanyId == CompanyId)).Select(b => new { id = b.Id, name = b.Name }).ToList(); ViewBag.FormulaId = _hrUnitOfWork.Repository <Formula>().Select(a => new { id = a.Id, name = a.Name }).ToList(); ViewBag.Desc = MsgUtils.Instance.Trls("salaryitemsDes"); return(View(new SalaryDesignSecondViewModel())); }
// GET: AssignOrder public ActionResult Index(int id = 0) { string RoleId = Request.QueryString["RoleId"]?.ToString(); int MenuId = Request.QueryString["MenuId"] != null?int.Parse(Request.QueryString["MenuId"].ToString()) : 0; ViewBag.isSSMenu = _hrUnitOfWork.Repository <Model.Domain.Menu>().Where(a => a.Id == MenuId).Select(a => a.SSMenu).FirstOrDefault(); if (id == 2) { ViewBag.MangRole = true; } else { ViewBag.MangRole = false; } string[] weekDays = { MsgUtils.Instance.Trls("Sunday"), MsgUtils.Instance.Trls("Monday"), MsgUtils.Instance.Trls("Tuesday"), MsgUtils.Instance.Trls("Wednesday"), MsgUtils.Instance.Trls("Thursday"), MsgUtils.Instance.Trls("Friday"), MsgUtils.Instance.Trls("Saturday") }; byte? weekend = _PersonSetup.Weekend2 ?? _PersonSetup.Weekend1; if (weekend != null) { byte firstDate = (byte)(weekend == 6 ? 0 : (weekend + 1)); ViewBag.week = "(" + weekDays[firstDate] + " - " + weekDays[weekend.Value] + ")"; } return(View()); }
//Kendo : Update ==>Currency public ActionResult UpdateLoanType(IEnumerable <LoanTypeViewModel> models, IEnumerable <OptionsViewModel> options) { var datasource = new DataSource <LoanTypeViewModel>(); datasource.Data = models; datasource.Total = models.Count(); if (ModelState.IsValid) { if (ServerValidationEnabled) { var errors = _hrUnitOfWork.LookUpRepository.Check(new CheckParm { CompanyId = CompanyId, ObjectName = "LoanTypes", TableName = "LoanTypes", Columns = Models.Utils.GetModifiedRows(ModelState.Where(a => a.Key.Contains("models"))), Culture = Language }); if (errors.Count() > 0) { datasource.Errors = errors; return(Json(datasource)); } } var ids = models.Select(a => a.Id); var db_LoanType = _hrUnitOfWork.Repository <LoanType>().Where(a => ids.Contains(a.Id)).ToList(); for (var i = 0; i < models.Count(); i++) { var loanType = db_LoanType.FirstOrDefault(a => a.Id == models.ElementAtOrDefault(i).Id); AutoMapper(new AutoMapperParm() { ObjectName = "LoanTypes", Destination = loanType, Source = models.ElementAtOrDefault(i), Version = 0, Options = options.ElementAtOrDefault(i), Transtype = TransType.Update, Id = "Id" }); _hrUnitOfWork.LoanTypeRepository.Attach(loanType); _hrUnitOfWork.LoanTypeRepository.Entry(loanType).State = EntityState.Modified; } datasource.Errors = SaveChanges(Language); } else { datasource.Errors = Models.Utils.ParseErrors(ModelState.Values); } if (datasource.Errors.Count() > 0) { return(Json(datasource)); } else { return(Json(datasource.Data)); } }
public ActionResult GetFirstmodel() { int Id = _hrUnitOfWork.Repository <CompanyStructure>().Where(a => a.CompanyId == CompanyId).Select(a => a.Id).FirstOrDefault(); var compstru = new CompanyStructureViewModel(); if (Id > 0) { compstru = _hrUnitOfWork.CompanyStructureRepository.GetStructure(Id, Language); } return(Json(compstru, JsonRequestBehavior.AllowGet)); }
public void fillViewBag() { ViewBag.Jobs = _hrUnitOfWork.JobRepository.GetAllJobs(CompanyId, Language, 0).Select(a => new { id = a.Id, name = a.LocalName }); ViewBag.Branches = _hrUnitOfWork.BranchRepository.ReadBranches(Language, CompanyId).Select(a => new { id = a.Id, name = a.LocalName }); ViewBag.CompanyStuctures = _hrUnitOfWork.CompanyStructureRepository.GetAllDepartments(CompanyId, null, Language); ViewBag.Payrolls = _hrUnitOfWork.Repository <Payrolls>().Select(a => new { id = a.Id, name = a.Name }); ViewBag.Positions = _hrUnitOfWork.PositionRepository.GetPositions(Language, CompanyId).Select(a => new { id = a.Id, name = a.Name }); ViewBag.PeopleGroups = _hrUnitOfWork.PeopleRepository.GetPeoples().Select(a => new { id = a.Id, name = a.Name }); ViewBag.PayrollGrades = _hrUnitOfWork.JobRepository.GetPayrollGrade(CompanyId); ViewBag.calender = _hrUnitOfWork.Repository <PeriodName>().Select(a => new { id = a.Id, name = a.Name }).ToList(); }
//CreateMsgs public ActionResult UpdateMsgTbl(IEnumerable <MsgTblViewModel> models, string culture) { var datasource = new DataSource <MsgTblViewModel>(); datasource.Data = models; datasource.Total = models.Count(); if (ModelState.IsValid) { if (ServerValidationEnabled) { var errors = _hrUnitOfWork.PageEditorRepository.Check(new CheckParm { CompanyId = CompanyId, ObjectName = "MsgTbl", Columns = Models.Utils.GetModifiedRows(ModelState.Where(a => a.Key.Contains("models"))), Culture = Language }); if (errors.Count() > 0) { datasource.Errors = errors; return(Json(datasource)); } } var msg = _hrUnitOfWork.Repository <MsgTbl>().Where(a => a.Culture == culture).ToList(); foreach (MsgTblViewModel p in models) { var MsgObj = msg.Where(a => a.SequenceId == p.Id).FirstOrDefault(); MsgObj.Name = p.Name; MsgObj.Meaning = p.Meaning; MsgObj.JavaScript = p.JavaScript; _hrUnitOfWork.AudiTrialRepository.Attach(MsgObj); _hrUnitOfWork.AudiTrialRepository.Entry(MsgObj).State = EntityState.Modified; } datasource.Errors = SaveChanges(Language); } else { datasource.Errors = Models.Utils.ParseErrors(ModelState.Values); } if (datasource.Errors.Count() > 0) { return(Json(datasource)); } else { return(Json(datasource.Data)); } }
protected override void OnActionExecuted(ActionExecutedContext filterContext) { base.OnActionExecuted(filterContext); if (Request.QueryString["MenuId"] == null) { return; } Session["MenuId"] = Request.QueryString["MenuId"]; if (Request.QueryString["RoleId"] != null) { Session["RoleId"] = Request.QueryString["RoleId"]; } else if (Session["RoleId"] == null) { Session["RoleId"] = HrUnitOfWork.MenuRepository.GetMenuRoleId(int.Parse(Session["MenuId"].ToString()), User.Identity.Name); } if (Session["DepartmentId"] == null) { var empid = User.Identity.GetEmpId(); var employee = HrUnitOfWork.Repository <Model.Domain.Assignment>().Where(a => a.EmpId == empid && (a.AssignDate <= DateTime.Today && a.EndDate >= DateTime.Today)).Select(b => new { b.DepartmentId, b.BranchId, b.IsDepManager, b.JobId, b.PositionId }).FirstOrDefault(); if (employee != null) { Session["DepartmentId"] = employee.DepartmentId; Session["PositionId"] = employee.PositionId; Session["IsDepManager"] = employee.IsDepManager.ToString(); Session["BranchId"] = employee.BranchId; Session["JobId"] = employee.JobId; } } }
public ActionResult Details(int id = 0) { int?position = null; if (Session["PositionId"] != null) { position = int.Parse(Session["PositionId"]?.ToString()); } ViewBag.Emps = _hrUnitOfWork.CheckListRepository.GetManagerEmpList(User.Identity.GetEmpId(), position, CompanyId, Language); EmpTask oldTask = _hrUnitOfWork.Repository <EmpTask>().Where(t => t.ManagerId == User.Identity.GetEmpId()).OrderByDescending(t => t.TaskNo).FirstOrDefault(); if (id == 0) { return(View(new EmpTasksViewModel() { TaskNo = (short)(oldTask != null ? (oldTask.TaskNo + 1) : 1), AssignedTime = DateTime.Now, Status = 1 })); } EmpTasksViewModel task = _hrUnitOfWork.CheckListRepository.GetManagerEmpTask(id); return(task == null ? (ActionResult)HttpNotFound() : View(task)); }
public ActionResult Details(int id = 0) { ViewBag.PeriodId = _hrUnitOfWork.BudgetRepository.GetCalender(CompanyId).Where(a => a.PeriodLength > 0).Select(a => new { id = a.Id, name = a.Name }); ViewBag.BankId = _hrUnitOfWork.Repository <Provider>().Where(a => a.ProviderType == 7).Select(a => new { id = a.Id, name = a.Name }); ViewBag.AccrualSalAcct = _hrUnitOfWork.Repository <Account>().Select(a => new { id = a.Id, name = a.Name }); ViewBag.PayrollDue = _hrUnitOfWork.Repository <PayrollDue>().Where(a => a.PayrollId == id).Select(a => new { value = a.Id, text = a.Name }); ViewBag.Calender = _hrUnitOfWork.LeaveRepository.GetHolidays(CompanyId); if (id == 0) { return(View(new PayrollFormViewModel())); } var record = _hrUnitOfWork.PayrollRepository.GetPayroll(id); return(record == null ? (ActionResult)HttpNotFound() : View(record)); }
void FillViewBag() { string culture = User.Identity.GetLanguage(); if (culture.Substring(0, 2) == "ar") { ViewBag.Country = _hrUnitOfWork.Repository <Country>().Select(c => new { id = c.Id, name = c.NameAr }); } else { ViewBag.Country = _hrUnitOfWork.Repository <Country>().Select(c => new { id = c.Id, name = c.Name }); } ViewBag.Culture = _hrUnitOfWork.AudiTrialRepository.ReadLanguage(); ViewBag.Company = _hrUnitOfWork.CompanyRepository.CompanyList(culture).Select(c => new { id = c.Id, name = c.Name }); ViewBag.Emp = _hrUnitOfWork.PeopleRepository.GetAllPeoples(User.Identity.GetLanguage()).Select(a => new { id = a.Id, name = a.Name, a.PicUrl, a.Icon }); }
public ActionResult Details(int id = 0) { //Get People ViewBag.PersonId = _hrUnitOfWork.TrainingRepository.GetPeople(Language).Select(a => new { id = a.Id, name = a.Title, PicUrl = a.PicUrl, Icon = a.EmpStatus }); ViewBag.CourseId = _hrUnitOfWork.TrainingRepository.GetTrainCourse(Language, CompanyId).Select(p => new { id = p.Id, name = p.LocalName }); // ViewBag.EventId = _hrUnitOfWork.TrainingRepository.GetAllEvents().Select(p => new { id = p.Id, name = p.Name}); ViewBag.EventId = _hrUnitOfWork.Repository <TrainEvent>().Select(p => new { id = p.Id, name = p.Name }); ViewBag.CurrCode = _hrUnitOfWork.LookUpRepository.GetCurrencyCode(); if (id == 0) { return(View(new PeopleTrainFormViewModel())); } var peopleTrain = _hrUnitOfWork.TrainingRepository.ReadPeopleTrain(id, Language); return(peopleTrain == null ? (ActionResult)HttpNotFound() : View(peopleTrain)); }
public IHttpActionResult GetJoined(int?LeveId) { int Id = User.Identity.GetEmpId(); Id = 1042; var type = _PersonSetup.WorkServMethod; var Emp = _hrUnitOfWork.Repository <Employement>().Where(a => a.Status == 1 && a.CompanyId == User.Identity.GetDefaultCompany() && a.EmpId == Id).Select(b => b).FirstOrDefault(); var date = Emp.StartDate; if (type == 1) { var newdate = _hrUnitOfWork.Repository <Person>().Where(a => a.Id == Id).Select(b => b.JoinDate == null ? new DateTime(2999, 1, 1) : b.JoinDate.Value).FirstOrDefault(); if (newdate != new DateTime(2999, 1, 1)) { date = newdate; } } double serveinYears = Math.Round((DateTime.Now.Subtract(date).TotalDays) / 365.25, 5); double BonusinMonth = 0; if (LeveId != null) { int syscode = _hrUnitOfWork.LookUpRepository.GetLookUpUserCodes("Termination", User.Identity.GetLanguage()).Where(a => a.CodeId == LeveId).Select(b => b.SysCodeId).FirstOrDefault(); var Periods = _hrUnitOfWork.Repository <TermDuration>().Where(a => a.CompanyId == User.Identity.GetDefaultCompany() && a.TermSysCode == syscode && a.WorkDuration >= Convert.ToByte(serveinYears)).FirstOrDefault(); if (Periods != null) { if (serveinYears > Periods.FirstPeriod) { BonusinMonth = Math.Round((Periods.FirstPeriod * Periods.Percent1) + (serveinYears - Periods.FirstPeriod) * (Periods.Percent2 == null ? 0 : Periods.Percent2.Value), 5); } else { BonusinMonth = Math.Round((serveinYears * Periods.Percent1), 5); } } } int[] arr = new int[] { 1, 2, 4 }; var EmpStatus = _hrUnitOfWork.LookUpRepository.GetLookUpUserCodes("PersonType", User.Identity.GetLanguage()).Where(a => a.SysCodeId == (arr.Contains(Emp.PersonType) ? 3 : 6)).Select(b => new { id = b.CodeId, name = b.Title }).ToList(); var myobj = new { date = date, bouns = BonusinMonth, ServYear = serveinYears, EmpStatus = EmpStatus }; return(Ok(myobj)); }
public void fillViewBag(int Id) { ViewBag.PrevCourses = _hrUnitOfWork.TrainingRepository.GetTrainCourse(Language, CompanyId).Where(a => a.Id != Id).Select(p => new { id = p.Id, name = p.LocalName }); ViewBag.Qualification = _hrUnitOfWork.Repository <Qualification>().Select(p => new { id = p.Id, name = p.Name }).ToList(); ViewBag.Course = _hrUnitOfWork.TrainingRepository.GetTrainCourse(Language, CompanyId).Select(p => new { value = p.Id, text = p.LocalName }); ViewBag.Branches = _hrUnitOfWork.BranchRepository.ReadBranches(Language, CompanyId).Select(a => new { id = a.Id, name = a.LocalName }); ViewBag.Jobs = _hrUnitOfWork.JobRepository.GetAllJobs(CompanyId, Language, 0).Select(a => new { id = a.Id, name = a.LocalName }); ViewBag.CompanyStuctures = _hrUnitOfWork.CompanyStructureRepository.GetAllDepartments(CompanyId, null, Language); ViewBag.Payrolls = _hrUnitOfWork.Repository <Payrolls>().Select(a => new { id = a.Id, name = a.Name }); ViewBag.Positions = _hrUnitOfWork.PositionRepository.GetPositions(Language, CompanyId).Select(a => new { id = a.Id, name = a.Name }); ViewBag.PeopleGroups = _hrUnitOfWork.PeopleRepository.GetPeoples().Select(a => new { id = a.Id, name = a.Name }); ViewBag.PayrollGrades = _hrUnitOfWork.JobRepository.GetPayrollGrade(CompanyId); }
public ActionResult Getchanges(ChangesObject obj) { List <ChangesViewmodel> chan = new List <ChangesViewmodel>(); var ls = _hrUnitOfWork.Repository <AudiTrail>().Where(a => (a.ColumnName == obj.columnname) && (a.CompanyId == obj.companyId) && (a.ObjectName == obj.objectname) && (a.SourceId == obj.sourceId) && (a.Version == obj.version)).OrderBy(b => b.ModifiedTime).Take(5).ToList(); foreach (var item in ls) { chan.Add(new ChangesViewmodel { Value = item.ValueAfter, ModifiedTime = item.ModifiedTime, ModifiedUser = item.ModifiedUser }); } if (ls.Count > 0) { chan.Add(new ChangesViewmodel { Value = ls.FirstOrDefault().ValueBefore, ModifiedUser = obj.CreatedUser, ModifiedTime = obj.CreatedTime }); } return(PartialView("changes", chan)); }
public ActionResult Details(int id = 0, int Read = 0) { ViewBag.TimeZones = TimeZoneInfo.GetSystemTimeZones().Select(a => new { id = a.Id, name = a.DisplayName }); ViewBag.Employees = _hrUnitOfWork.PeopleRepository.GetActiveEmployees(CompanyId, Language).ToList(); if (id == 0) { return(View(new AddSiteViewModel())); } var site = _hrUnitOfWork.SiteRepository.ReadSite(id, Read, Language); if (site.CountryId > 0) { var city = site.CityId ?? 0; var dist = site.DistrictId ?? 0; var loc = _hrUnitOfWork.Repository <World>().FirstOrDefault(c => c.CountryId == site.CountryId && c.CityId == city && c.DistrictId == dist); if (site != null) { site.Site = (Language.Substring(0, 2) == "ar" ? loc.NameAr : loc.Name); } } return(site == null ? (ActionResult)HttpNotFound() : View(site)); }
public ActionResult Index() { var Code = _hrUnitOfWork.Repository <PayrollGrade>().DefaultIfEmpty().Max(a => a == null ? 0 : a.Code); ViewBag.Code = Code + 1; return(View()); }
public ActionResult Index1() { int Id = _hrUnitOfWork.Repository <Menu>().Select(a => a.Id).FirstOrDefault(); var menu = _hrUnitOfWork.MenuRepository.GetMenu(Id, Language); ViewBag.Functions = _hrUnitOfWork.MenuRepository.Functions().ToList(); return(View(menu)); }
public string GetCompanyLogo(int Id, string Name) { var query = _hrUnitOfWork.Repository <CompanyDocsViews>() .Where(d => d.CompanyId == Id && d.TypeId == 1) .Select(d => new { name = d.name }) .ToList(); if (query.Count == 0 || Name == query[0].name) { return("0"); } else { return(query[0].name); } }
public ActionResult Details(int id = 0) { ViewBag.TimeZones = TimeZoneInfo.GetSystemTimeZones().Select(a => new { id = a.Id, name = a.DisplayName }); if (id == 0) { return(View(new AddBranchViewModel())); } var branch = _hrUnitOfWork.BranchRepository.ReadBranch(id, Language); if (branch.CountryId > 0) { var city = branch.CityId ?? 0; var dist = branch.DistrictId ?? 0; var loc = _hrUnitOfWork.Repository <World>().FirstOrDefault(c => c.CountryId == branch.CountryId && c.CityId == city && c.DistrictId == dist); if (branch != null) { branch.Site = (Language.Substring(0, 2) == "ar" ? loc.NameAr : loc.Name); } } return(branch == null ? (ActionResult)HttpNotFound() : View(branch)); }
public ActionResult Details(int Id, byte Btn) { //Btn: 1.Edit, 2.Cancel, 3.Break LeaveOpViewModel request = _hrUnitOfWork.LeaveRepository.GetLeaveOpReq(Id, Language); request.btn = Btn; ViewBag.CalcOptions = _hrUnitOfWork.LeaveRepository.GetLeaveType(request.TypeId); //for Calender ViewBag.Calender = _hrUnitOfWork.LeaveRepository.GetHolidays(CompanyId); //for Calender int MenuId = Request.QueryString["MenuId"] != null?int.Parse(Request.QueryString["MenuId"].ToString()) : 0; ViewBag.isSSMenu = _hrUnitOfWork.Repository <Model.Domain.Menu>().Where(a => a.Id == MenuId).Select(a => a.SSMenu).FirstOrDefault(); return(View(request)); }
public ActionResult CheckDefault(int?Id, int ListTypeId) { var Def = _hrUnitOfWork.Repository <CheckList>().Where(a => a.ListType == ListTypeId && a.Default == true).Select(d => d).FirstOrDefault(); if (Def == null) { Def = new CheckList(); Def.Default = true; } else if (Def.Id == Id) { Def.Default = true; } else if (Id != Def.Id) { Def.Default = false; } else { Def.Default = false; } return(Json(Def, JsonRequestBehavior.AllowGet)); }
public ActionResult Details(int id = 0, byte Version = 0) { var Medical = _hrUnitOfWork.MedicalRepository.ReadMedical(id); ViewBag.BenefitId = _hrUnitOfWork.MedicalRepository.FillDDLBenefit(User.Identity.GetLanguage()); // TODO //if (User.Identity.IsSelfServiceUser()) //{ // int EmpId = User.Identity.GetEmpId(); // ViewBag.BeneficiaryId = _hrUnitOfWork.Repository<EmpRelative>().Where(a => a.EmpId == EmpId).Select(p => new { id = p.Id, name = p.Name }).ToList(); // // ViewBag.Services = _hrUnitOfWork.MedicalRepository.GetAllservice(EmpId,0); //} if (Medical != null) { ViewBag.BeneficiaryId = _hrUnitOfWork.Repository <EmpRelative>().Where(a => a.EmpId == Medical.EmpId).Select(p => new { id = p.Id, name = p.Name }); ViewBag.Services = _hrUnitOfWork.MedicalRepository.GetAllservice(Medical.EmpId, Medical.BenefitId, Medical.BeneficiaryId); } ViewBag.Providers = _hrUnitOfWork.MedicalRepository.GetAllProvider(); ViewBag.Currency = _hrUnitOfWork.LookUpRepository.GetCurrencyCode(); string culture = Language; if (!_hrUnitOfWork.LeaveRepository.CheckAutoCompleteColumn("MedicalRequestsForm", CompanyId, Version, "EmpId")) { ViewBag.Employees = _hrUnitOfWork.EmployeeRepository.GetActiveEmployees(Language, Medical != null ? Medical.EmpId : 0, CompanyId).Select(a => new { id = a.Id, name = a.Employee, PicUrl = a.PicUrl, Icon = a.EmpStatus }); } if (id == 0) { return(View(new MedicalRequestViewModel())); } return(Medical == null ? (ActionResult)HttpNotFound() : View(Medical)); }
private string ChangeAssignmentStatus(LeaveRequest request) { LeaveType type; //if future assignment && leave type chanege assignment -> prevent string assignError = _hrUnitOfWork.LeaveRepository.CheckAssignStatus(request.EmpId, request.TypeId, out type, User.Identity.GetLanguage()); if (!string.IsNullOrEmpty(assignError)) { return(assignError); } if (type.AssignStatus != null) { Assignment copy = _hrUnitOfWork.EmployeeRepository.Find(a => a.EmpId == request.EmpId && a.AssignDate <= DateTime.Today.Date && a.EndDate >= DateTime.Today.Date).FirstOrDefault(); short oldAssignStatus = copy.AssignStatus; short oldSysAssignStatus = copy.SysAssignStatus; copy.EndDate = request.ActualStartDate.Value.AddDays(-1); copy.ModifiedUser = User.Identity.Name; copy.ModifiedTime = DateTime.Now; _hrUnitOfWork.EmployeeRepository.Attach(copy); _hrUnitOfWork.EmployeeRepository.Entry(copy).State = EntityState.Modified; Assignment assignLeave = new Assignment(); AutoMapper(new Models.AutoMapperParm() { Source = copy, Destination = assignLeave }); assignLeave.AssignStatus = type.AssignStatus.Value; assignLeave.SysAssignStatus = _hrUnitOfWork.Repository <LookUpUserCode>().Where(a => a.CodeName == "Assignment" && a.CodeId == type.AssignStatus.Value).Select(a => a.SysCodeId).FirstOrDefault(); assignLeave.AssignDate = request.ActualStartDate.Value; assignLeave.CreatedUser = User.Identity.Name; assignLeave.CreatedTime = DateTime.Now; if (type.AutoChangStat == 1) //1-Automatic return to original status before leave { assignLeave.EndDate = request.ActualEndDate.Value; _hrUnitOfWork.EmployeeRepository.Add(assignLeave); //i Assignment returnAssign = new Assignment(); AutoMapper(new Models.AutoMapperParm() { Source = copy, Destination = returnAssign }); returnAssign.AssignStatus = oldAssignStatus; returnAssign.SysAssignStatus = oldSysAssignStatus; returnAssign.AssignDate = request.ActualEndDate.Value.AddDays(1); returnAssign.EndDate = new DateTime(2099, 1, 1); returnAssign.CreatedUser = User.Identity.Name; returnAssign.CreatedTime = DateTime.Now; _hrUnitOfWork.EmployeeRepository.Add(returnAssign); //ii } else { assignLeave.EndDate = new DateTime(2099, 1, 1); _hrUnitOfWork.EmployeeRepository.Add(assignLeave); //i } var assignmentCodes = _hrUnitOfWork.LookUpRepository.GetLookUpUserCodes("Assignment", User.Identity.GetLanguage()); _hrUnitOfWork.TrainingRepository.AddTrail(new AddTrailViewModel() { ColumnName = "AssignStatus", CompanyId = User.Identity.GetDefaultCompany(), ObjectName = "AssignmentsForm", SourceId = copy.Id.ToString(), UserName = User.Identity.Name, ValueAfter = assignmentCodes.FirstOrDefault(a => a.CodeId == type.AssignStatus.Value).Name, ValueBefore = assignmentCodes.FirstOrDefault(a => a.CodeId == oldAssignStatus).Name }); } return(null); }
private List <Error> SaveGrid1(IEnumerable <PayRequestEmpsViewModel> grid1, IEnumerable <KeyValuePair <string, ModelState> > state, PayRequest payRequest) { List <Error> errors = new List <Error>(); if (ServerValidationEnabled) { var modified = Models.Utils.GetModifiedRows(state.Where(a => !a.Key.Contains("deleted"))); if (modified.Count > 0) { errors = _hrUnitOfWork.CompanyRepository.Check(new CheckParm { CompanyId = CompanyId, ObjectName = "PayRequestEmployees", Columns = Models.Utils.GetModifiedRows(state.Where(a => !a.Key.Contains("deleted"))), Culture = Language }); if (errors.Count() > 0) { return(errors); } } } var allRequestDets = _hrUnitOfWork.Repository <PayRequestDet>().Where(p => p.RequestId == payRequest.Id); var deleted = allRequestDets.Where(p => grid1.Where(i => i.EmpId == p.EmpId).Count() == 0).ToList(); foreach (PayRequestEmpsViewModel model in grid1) { PayRequestDet PayDet; if (model.Id == 0) // inserted records { PayDet = new PayRequestDet(); AutoMapper(new Models.AutoMapperParm { Destination = PayDet, Source = model, Transtype = TransType.Insert }); PayDet.Request = payRequest; _hrUnitOfWork.PayrollRepository.Add(PayDet); } else if (model.dirty) // updated records { PayDet = allRequestDets.Where(e => e.EmpId == model.EmpId).FirstOrDefault(); AutoMapper(new Models.AutoMapperParm { Destination = PayDet, Source = model, Transtype = TransType.Update }); _hrUnitOfWork.PayrollRepository.Attach(PayDet); _hrUnitOfWork.PayrollRepository.Entry(PayDet).State = EntityState.Modified; } } if (deleted.Count > 0) { foreach (PayRequestDet model in deleted) { _hrUnitOfWork.PayrollRepository.Remove(model); } } return(errors); }
public ActionResult Details(int id = 0) { ViewBag.Account = _hrUnitOfWork.Repository <Account>().Select(a => new { id = a.Id, name = a.Name }); ViewBag.TstFormula = _hrUnitOfWork.Repository <Formula>().Select(a => new { id = a.Id, name = a.Name }); ViewBag.Curr = _hrUnitOfWork.LookUpRepository.GetCurrencyCode(); if (id == 0) { return(View(new SalaryItemFormViewModel())); } var record = _hrUnitOfWork.PayrollRepository.GetSalaryItem(id); return(record == null ? (ActionResult)HttpNotFound() : View(record)); }
public IHttpActionResult PurposeList() { return(Json(_hrUnitOfWork.Repository <LookUpCode>().Where(c => c.CodeName == "Purpose").Select(c => new { Purpose = c.Name }).ToList())); }