protected void TryResizeIfNeed(IEmployeeRelationService service) { EmployeeRelation firstRange = null; EmployeeRelation lastRange = null; if (_Relations != null && _Relations.Count > 0) { _Relations.Sort(); firstRange = _Relations[0]; if (firstRange.BeginTime != BeginDate) { firstRange.BeginTime = BeginDate; } lastRange = _Relations[_Relations.Count - 1]; if (firstRange.EndTime != EndDate) { firstRange.EndTime = EndDate; } if (_Relations.Count == 1) { service.SaveOrUpdate(firstRange); } else { service.SaveOrUpdate(firstRange); service.SaveOrUpdate(lastRange); } } if (NextContract != null) { NextContract.TryResizeIfNeed(service); } }
/// <summary> /// Updates the current world assignment. BeginDate and EndDate should be EXACTLY THE SAME as of existing relation. /// </summary> /// <param name="newEmployeeRelation">The new employee relation.</param> /// acpro #122269 public void UpdateAssignment(EmployeeRelation newEmployeeRelation) { DoValidate(newEmployeeRelation); _EmployeeRelation newRelation = new _EmployeeRelation(newEmployeeRelation); List <_EmployeeRelation> intersectedRelations = _commonList.FindAll(delegate(_EmployeeRelation relation) { if (relation.IsIntersectRelation(newRelation) || (relation.IsEqualByData(newRelation) && relation.IsNeighborRelation(newRelation))) { if (!relation.IsEqualByStore(newRelation) && !IsMainStoreRelation(newRelation)) { throw new ValidationException("ErrorAssignToWorldDateRangeIntersect", null); } return(true); } return(false); }); //Debug.Assert(intersectedRelations.Count == 1); //Debug.Assert(intersectedRelations[0].BeginTime == newEmployeeRelation.BeginTime); //Debug.Assert(intersectedRelations[0].EndTime == newEmployeeRelation.EndTime); intersectedRelations[0].StoreID = newRelation.StoreID; intersectedRelations[0].WorldID = newRelation.WorldID; intersectedRelations[0].HWGR_ID = newRelation.HWGR_ID; }
public override void Add() { if (Context != null && FocusedEntity != null && Context.CurrentStore != null) { List <Domain.StoreToWorld> lst = null; lst = swController.GetListByStoreId(Context.CurrentStore.ID); if (lst.Count == 0) { lst = ClientEnvironment.StoreToWorldService.FindAllForStore(Context.CurrentStore.ID); swController.AddList(lst); } using (FormAssignEmployeeToWorld assignform = new FormAssignEmployeeToWorld()) { Domain.Employee empl = Context.CurrentEmployee; EmployeeRelation relation = new EmployeeRelation(); relation.EmployeeID = empl.ID; relation.EmployeeName = empl.FullName; relation.WorldID = 0; if (FocusedEntity != null) { relation.WorldID = FocusedEntity.WorldID; relation.BeginTime = FocusedEntity.BeginTime; if (relation.BeginTime < DateTime.Today) { relation.BeginTime = DateTime.Today; } relation.EndTime = FocusedEntity.EndTime; if (relation.BeginTime > relation.EndTime) { relation.EndTime = Contract.DateTimeSql.SmallDatetimeMax; } } Context.CurrentRelation = relation; assignform.SetWorldList(swController.GetListByStoreId(Context.CurrentStore.ID)); assignform.Entity = Context; if (assignform.ShowDialog() == DialogResult.OK) { LoadEmployeeRelation(); if (Context.Relations != null) { Domain.Employee employee = ClientEnvironment.EmployeeService.GetEmployeeByID(empl.ID, DateTime.Now); if (Context.EmployeeList != null && employee != null) { Context.EmployeeList.SetEntity(employee); } } } } } }
public void SynchronizeToContract(DateTime date) { _relations = ExEmployeeRelation.List(EmployeeId); if (_relations == null) { return; } EmployeeRelation entity = _relations[_relations.Count - 1]; if (entity.EndTime < date) { entity.EndTime = date; ExEmployeeRelation.Update(entity); } else { foreach (EmployeeRelation next_entity in _relations) { if (next_entity.IsContainDate(date)) { next_entity.EndTime = date; ExEmployeeRelation.Update(next_entity); } else if (next_entity.BeginTime > date) { ExEmployeeRelation.Delete(next_entity); } } } _relations = null; }
private EmployeeRelation CreateCopy() { EmployeeRelation newrelation = new EmployeeRelation(); CopyTo(m_owner, newrelation); newrelation.ID = 0; return(newrelation); }
public bool Include(EmployeeRelation relation) { if (relation == null) { return(false); } return(DateTimeHelper.Include(relation.BeginTime, relation.EndTime, BeginDate, EndDate)); }
EmployeeRelation GetEntityByRowHandle(int rowHandle) { EmployeeRelation relation = null; if (gridViewEntities.IsDataRow(rowHandle)) { relation = (EmployeeRelation)gridViewEntities.GetRow(rowHandle); } return(relation); }
public void CheckAndModify(EmployeeRelation relation, IEmployeeRelationService service) { if (CheckIfOutside(relation)) { //relation.EndTime = relation.BeginTime.AddDays(-1); service.Delete(relation); return; } if (Include(relation)) { Relations.Add(relation); return; } else if (DateTimeHelper.IsIntersectExc(relation.BeginTime, relation.EndTime, BeginDate, EndDate)) { if (DateTimeHelper.Between(relation.BeginTime, BeginDate, EndDate)) { EmployeeRelation newrelation = relation.GetCopy(); newrelation.ID = 0; newrelation.BeginTime = NextDay; relation.EndTime = EndDate; Debug.Assert(relation.IsValidRelation()); Relations.Add(relation); service.SaveOrUpdate(relation); relation = newrelation; } else if (DateTimeHelper.Between(relation.EndTime, BeginDate, EndDate)) { EmployeeRelation newrelation = relation.GetCopy(); newrelation.ID = 0; newrelation.EndTime = PrevDay; relation.BeginTime = BeginDate; Debug.Assert(relation.IsValidRelation()); Relations.Add(relation); service.SaveOrUpdate(relation); relation = newrelation; } if (NextContract != null) { NextContract.CheckAndModify(relation, service); } } else if (NextContract != null) { NextContract.CheckAndModify(relation, service); } return; }
public bool CheckIfOutside(EmployeeRelation relation) { if (NextContract == null) { return(true); } DateTime nextBeginDate = NextContract.BeginDate.AddDays(-1); if (DateTimeHelper.Include(relation.BeginTime, relation.EndTime, NextDay, nextBeginDate)) { return(false); } return(NextContract.CheckIfOutside(relation)); }
public void AssignToWorld() { if (EntityStore != null && FocusedEntity != null) { List <StoreToWorld> lst = GetStoreWorldList(EntityStore.ID); using (FormAssignEmployeeToWorld assignform = new FormAssignEmployeeToWorld()) { Domain.Employee empl = FocusedEntity; Context.CurrentEmployee = empl; EmployeeRelation relation = new EmployeeRelation(); relation.EmployeeID = empl.ID; relation.EmployeeName = empl.FullName; relation.StoreID = Context.CurrentStore.ID; relation.WorldID = empl.WorldID; relation.BeginTime = DateTime.Today; relation.EndTime = empl.ContractEnd; if (IsDeligatedEmployee && empl.EndTime.HasValue) { relation.EndTime = empl.EndTime.Value; } Context.CurrentRelation = relation; assignform.SetWorldList(_swController.GetListByStoreId(EntityStore.ID)); assignform.Entity = Context; if (assignform.ShowDialog() == DialogResult.OK) { Domain.Employee employee = ClientEnvironment.EmployeeService.GetEmployeeByID(empl.ID, DateTime.Today); if (employee != null) { Context.EmployeeList.SetEntity(employee); } } } } }
protected override bool SaveEntity() { if (ValidateEntity()) { EmployeeRelation relation = new EmployeeRelation(); relation.StoreID = FocusedEntity.ID; relation.EmployeeID = EntityEmployee.ID; relation.BeginTime = BeginTime; relation.EndTime = EndTime; List <Domain.World> lst = ClientEnvironment.WorldService.FindAll(); if (lst != null) { foreach (Domain.World w in lst) { if (w.WorldTypeID == WorldType.Administration) { relation.WorldID = w.ID; } } } try { ClientEnvironment.EmployeeRelationService.InsertDeligationToStore(relation); m_modified = true; return(true); } catch (ValidationException ex) { string localizedMessage = GetLocalized(ex.Message); if (String.IsNullOrEmpty(localizedMessage)) { localizedMessage = GetLocalized("ErrorAssignToWorldDateRangeIntersect"); } ErrorMessage(localizedMessage); return(false); } } else { return(false); } }
public override void Delete() { if (DeleteEnabled) { if (QuestionMessageYes(GetLocalized("QuestionDeleteEmployeeWorld"))) { EmployeeRelation relation = FocusedEntity; try { ClientEnvironment.EmployeeRelationService.DeleteByID(relation.ID); gridViewEntities.DeleteRow(gridViewEntities.FocusedRowHandle); } catch (EntityException ex) { ProcessEntityException(ex); } } } }
public bool CheckRelation(EmployeeRelation relation) { if (relation == null) { return(false); } if (Include(relation)) { return(true); } if (NextContract != null) { return(NextContract.CheckRelation(relation)); } return(false); }
private void DoValidate(EmployeeRelation newEmployeeRelation) { // Validation: EmployeeRelation should be withing Employee's contract time. ListEmployeeContracts contracts = new ListEmployeeContracts(_contractservice, _employee.ID); UnbreakContract validator = contracts.GetUnbreakContracts(); if (!validator.CheckRelation(newEmployeeRelation)) { throw new ValidationException("ErrorRelationOutsideContractTime", null); } //if (newEmployeeRelation.BeginTime < _employee.ContractBegin || newEmployeeRelation.EndTime > _employee.ContractEnd) //{ // throw new ValidationException("ErrorRelationOutsideContractTime", null); //} // Validation: Is Time planning is already defined within time range of new relation, ValidationExceptin is thrown if (_employeeDao.HasWorkingOrAbsenceTime(_employee.ID, newEmployeeRelation.BeginTime, newEmployeeRelation.EndTime)) { throw new ValidationException("ErrorTimePlanningAlreadyDefined", null); } }
public void InsertWorldAssignment(EmployeeRelation newEmployeeRelation) { DoValidate(newEmployeeRelation); _EmployeeRelation newRelation = new _EmployeeRelation(newEmployeeRelation); List <_EmployeeRelation> intersectedRelations = _commonList.FindAll(delegate(_EmployeeRelation relation) { if (relation.IsIntersectRelation(newRelation) || (relation.IsEqualByData(newRelation) && relation.IsNeighborRelation(newRelation))) { if (!relation.IsEqualByStore(newRelation) && !IsMainStoreRelation(newRelation)) { throw new ValidationException("ErrorAssignToWorldDateRangeIntersect", null); } return(true); } return(false); }); intersectedRelations.Sort(_comparer); InsertRelation2(newRelation, intersectedRelations); }
protected override bool SaveEntity() { if (ValidateEntity()) { EmployeeRelation relation = new EmployeeRelation(); relation.StoreID = FocusedEntity.ID; relation.EmployeeID = EntityEmployee.ID; relation.BeginTime = BeginTime; relation.EndTime = EndTime; List<Domain.World> lst = ClientEnvironment.WorldService.FindAll(); if (lst != null) { foreach (Domain.World w in lst) { if (w.WorldTypeID == WorldType.Administration) relation.WorldID = w.ID; } } try { ClientEnvironment.EmployeeRelationService.InsertDeligationToStore(relation); m_modified = true; return true; } catch (ValidationException ex) { string localizedMessage = GetLocalized(ex.Message); if (String.IsNullOrEmpty(localizedMessage)) { localizedMessage = GetLocalized("ErrorAssignToWorldDateRangeIntersect"); } ErrorMessage(localizedMessage); return false; } } else return false; }
public override void Add() { if (Context != null && FocusedEntity != null && Context.CurrentStore !=null) { List<Domain.StoreToWorld> lst = null; lst = swController.GetListByStoreId(Context.CurrentStore.ID); if (lst.Count == 0) { lst = ClientEnvironment.StoreToWorldService.FindAllForStore(Context.CurrentStore.ID); swController.AddList(lst); } using (FormAssignEmployeeToWorld assignform = new FormAssignEmployeeToWorld()) { Domain.Employee empl = Context.CurrentEmployee; EmployeeRelation relation = new EmployeeRelation(); relation.EmployeeID = empl.ID; relation.EmployeeName = empl.FullName; relation.WorldID = 0; if (FocusedEntity != null) { relation.WorldID = FocusedEntity.WorldID; relation.BeginTime = FocusedEntity.BeginTime; if (relation.BeginTime < DateTime.Today) relation.BeginTime = DateTime.Today; relation.EndTime = FocusedEntity.EndTime; if (relation.BeginTime > relation.EndTime) relation.EndTime = Contract.DateTimeSql.SmallDatetimeMax; } Context.CurrentRelation = relation; assignform.SetWorldList(swController.GetListByStoreId(Context.CurrentStore.ID)); assignform.Entity = Context; if (assignform.ShowDialog() == DialogResult.OK) { LoadEmployeeRelation(); if (Context.Relations != null) { Domain.Employee employee = ClientEnvironment.EmployeeService.GetEmployeeByID(empl.ID, DateTime.Now); if (Context.EmployeeList != null && employee != null) { Context.EmployeeList.SetEntity(employee); } } } } } }
public List <EmployeeWeek> BuildEmployeeWeeks(long storeid, long worldid, DateTime aBegin, DateTime aEnd, bool bPlanning) { Store store = ServerEnvironment.StoreService.FindById(storeid); if (store == null) { return(null); } long countryid = store.CountryID; bool IsAustria = store.CountryID == ServerEnvironment.CountryService.AustriaCountryID; // list of all employee for storeid and world IList employees = EmployeeService.EmployeeDao.GetPlanningEmployeesByWorld(storeid, worldid, aBegin, aEnd); if (employees == null && employees.Count == 0) { return(null); } long[] ids = new long[employees.Count]; for (int i = 0; i < employees.Count; i++) { ids[i] = (employees[i] as Employee).ID; } EmployeeRelationService relationService = EmployeeService.EmployeeRelationService as EmployeeRelationService; List <EmployeeRelation> emplRelations = relationService.GetEmployeeRelationsByEmployeeIds(ids, aBegin, aEnd); //CountryStoreWorldManager swmanager = new CountryStoreWorldManager(EmployeeService.StoreWorldService); //swmanager.StoreId = storeid; if (swCountryManager == null) { //long countryid = EmployeeService.StoreService.GetCountryByStoreId(storeid); swCountryManager = new CountryStoreWorldManager(EmployeeService.StoreWorldService); swCountryManager.CountryId = countryid; } List <EmployeeLongTimeAbsence> emplLongTimeAbsences = EmployeeService.EmployeeLongTimeAbsenceService.GetEmployeesHasLongTimeAbsence(ids, aBegin, aEnd); EmployeeLongTimeAbsenceIndexer absenceIndexer = new EmployeeLongTimeAbsenceIndexer(emplLongTimeAbsences); DictionListEmployeeRelations relationIndexer = new DictionListEmployeeRelations(emplRelations); List <EmployeeContract> contracts = EmployeeService.EmployeeContractService.GetEmployeeContracts(ids, aBegin, aEnd); ContractIndexer = new DictionListEmployeesContract(contracts); // applly relations EmployeeRelation relationWorld = null; bool bExistsRelation = false; bool bExistsContract = false; bool bNotExistsAbsence = true; _listweeks = new List <EmployeeWeek>(); EmployeeWeek emplWeek = null; foreach (Employee empl in employees) { emplWeek = new EmployeeWeek(empl.ID, empl.FullName, aBegin, aEnd, empl.OrderHwgrID.HasValue ? empl.OrderHwgrID.Value : 0); emplWeek.LastSaldo = (int)Math.Round(empl.BalanceHours); bExistsRelation = false; foreach (EmployeeDay d in emplWeek.DaysList) { relationWorld = relationIndexer.GetRelationEntity(empl.ID, d.Date); if (relationWorld != null) { d.StoreWorldId = swCountryManager.GetStoreWorldIdByStoreAndWorldId(relationWorld.StoreID, relationWorld.WorldID.Value); d.StoreId = relationWorld.StoreID; } bExistsRelation |= d.HasRelation; } if (bExistsRelation) { bExistsContract = ContractIndexer.FillEmployeeWeek(emplWeek); if (bExistsContract) { bNotExistsAbsence = absenceIndexer.FillEmployeeWeek(emplWeek); if (bNotExistsAbsence) { _listweeks.Add(emplWeek); } } } } FillEmployeeDayByStoreDay(storeid, aBegin, aEnd); _dictionWeek = EmployeeWeekProcessor.GetDictionary(_listweeks); _employeeids = EmployeeWeekProcessor.GetEmployeeIds(_listweeks); if (bPlanning) { FillPlanningEmployeeWeeks(storeid, worldid, aBegin, aEnd); } else { FillActualEmployeeWeeks(storeid, worldid, aBegin, aEnd); } //LastSaldoBuilder saldoBuilder = new LastSaldoBuilder(); LastSaldoBuilder saldoBuilder = (IsAustria) ? new LastSaldoBuilderAustria() : new LastSaldoBuilder(); saldoBuilder.FillLastSaldo(_dictionWeek, _employeeids, aBegin, bPlanning); EmployeeMonthWorkingTime monthData = new EmployeeMonthWorkingTime(EmployeeService.EmployeeTimeService as EmployeeTimeService); monthData.IsPlanning = bPlanning; monthData.CurrentMonday = aBegin; CacheEmployeesAllIn managerAllIn = new CacheEmployeesAllIn(); managerAllIn.LoadByStoreRelation(storeid); foreach (EmployeeWeek ew in _listweeks) { ew.WorkingTimeByMonth = monthData.GetMonthWorkingTime(ew.EmployeeId); ew.CountSaturday = (byte)monthData.CountSaturday; ew.CountSunday = (byte)monthData.CountSunday; ew.WorkingDaysBefore = (byte)monthData.WorkingDaysBefore; ew.WorkingDaysAfter = (byte)monthData.WorkingDaysAfter; ew.AllIn = managerAllIn.GetAllIn(ew.EmployeeId, aBegin, aEnd); } return(_listweeks); }
////////////////////////////////////////////////////////////////////////////////////// public EmployeeWeek BuildEmployeeWeek(long emplid, DateTime aBeginWeek) { if (aBeginWeek.DayOfWeek != DayOfWeek.Monday) { throw new ArgumentException(); } if (emplid <= 0) { throw new ArgumentException(); } Employee empl = EmployeeService.FindById(emplid); if (empl == null) { throw new ArgumentNullException(); } long[] ids = new long[] { emplid }; DateTime aEndWeek = DateTimeHelper.GetSunday(aBeginWeek); EmployeeRelationService relationService = EmployeeService.EmployeeRelationService as EmployeeRelationService; List <EmployeeLongTimeAbsence> emplLongTimeAbsences = EmployeeService.EmployeeLongTimeAbsenceService.GetEmployeesHasLongTimeAbsence(ids, aBeginWeek, aEndWeek); EmployeeLongTimeAbsenceIndexer absenceIndexer = new EmployeeLongTimeAbsenceIndexer(emplLongTimeAbsences); List <EmployeeRelation> emplRelations = relationService.GetEmployeeRelationsByEmployeeIds(ids, aBeginWeek, aEndWeek); DictionListEmployeeRelations relationIndexer = new DictionListEmployeeRelations(emplRelations); List <EmployeeContract> contracts = EmployeeService.EmployeeContractService.GetEmployeeContracts(ids, aBeginWeek, aEndWeek); DictionListEmployeesContract contractIndexer = new DictionListEmployeesContract(contracts); EmployeeWeek emplWeek = new EmployeeWeek(emplid, "", aBeginWeek, aEndWeek, empl.OrderHwgrID.HasValue ? empl.OrderHwgrID.Value : 0); EmployeeRelation relationWorld = null; bool bExistsRelation = false; bool bExistsContract = false; bool bNotExistsAbsence = true; if (swCountryManager == null) { long countryid = EmployeeService.StoreService.GetCountryByStoreId(empl.MainStoreID); swCountryManager = new CountryStoreWorldManager(EmployeeService.StoreWorldService); swCountryManager.CountryId = countryid; } bExistsContract = contractIndexer.FillEmployeeWeek(emplWeek); if (bExistsContract) { bNotExistsAbsence = absenceIndexer.FillEmployeeWeek(emplWeek); if (bNotExistsAbsence) { foreach (EmployeeDay d in emplWeek.DaysList) { relationWorld = relationIndexer.GetRelationEntity(emplid, d.Date); if (relationWorld != null) { d.StoreWorldId = swCountryManager.GetStoreWorldIdByStoreAndWorldId(relationWorld.StoreID, relationWorld.WorldID.Value); d.StoreId = relationWorld.StoreID; } bExistsRelation |= d.HasRelation; } } } if (!bExistsContract || !bExistsRelation || !bNotExistsAbsence) { emplWeek = null; } return(emplWeek); }
public _EmployeeRelation(EmployeeRelation rel) { m_owner = rel; _ID = rel.ID; }
public int SaveResourcetSet(MainResoureViewModel model) { //AspNetUser AddUser = _db.AspNetUsers.Where(x => x.Id == model.Id).FirstOrDefault(); AspNetUser AddUser = new AspNetUser(); //step 1 AddUser.NameTitle = model.Title; AddUser.FirstName = model.FirstName; AddUser.LastName = model.LastName; AddUser.OtherNames = model.OtherNames; AddUser.KnownAs = model.KnownAs; AddUser.SSOID = model.SSO.ToUpper(); AddUser.UserName = model.UserNameEmail; AddUser.IMAddress = model.IMAddress; AddUser.Gender = model.Gender; AddUser.Archived = false; AddUser.PasswordHash = model.PasswordHash; AddUser.CreatedDate = DateTime.Now; AddUser.CreatedBy = SessionProxy.UserId; if (model.DateOfBirth != null) { var DateOfBirthToString = DateTime.ParseExact(model.DateOfBirth, inputFormat, CultureInfo.InvariantCulture); AddUser.DateOfBirth = Convert.ToDateTime(DateOfBirthToString.ToString(outputFormat)); } AddUser.Nationality = model.Nationality; AddUser.NINumberSSN = model.NIN_SSN; AddUser.image = model.Picture; AddUser.IsReadAddReport = false; AddUser.IsReadArchived = false; AddUser.IsReadHRRespo = false; //Step 2 if (model.StartDate != null) { var StartDateToString = DateTime.ParseExact(model.StartDate, inputFormat, CultureInfo.InvariantCulture); AddUser.StartDate = Convert.ToDateTime(StartDateToString.ToString(outputFormat)); } AddUser.ResourceType = model.ResourceType; //AddUser.Reportsto = model.Reportsto; AddUser.AdditionalReportsto = model.AdditionalReportsto; AddUser.HRResponsible = model.HRResponsible; AddUser.JobTitle = model.JobTitle; AddUser.JobContryID = model.JobCountrID; AddUser.Location = model.Location; //AddUser.BusinessID = model.BusinessID; //AddUser.DivisionID = model.DivisionID; //AddUser.PoolID = model.PoolID; //AddUser.FunctionID = model.FunctionID; //step 3 if (model.ProbationEndDate != null) { var ProbationEndDateToString = DateTime.ParseExact(model.ProbationEndDate, inputFormat, CultureInfo.InvariantCulture); AddUser.ProbationEndDate = Convert.ToDateTime(ProbationEndDateToString.ToString(outputFormat)); } if (model.NextProbationReviewDate != null) { var NextProbationReviewDateToString = DateTime.ParseExact(model.NextProbationReviewDate, inputFormat, CultureInfo.InvariantCulture); AddUser.ProbationEndDate = Convert.ToDateTime(NextProbationReviewDateToString.ToString(outputFormat)); } if (model.FixedTermEndDate != null) { var FixedTermEndDateToString = DateTime.ParseExact(model.FixedTermEndDate, inputFormat, CultureInfo.InvariantCulture); AddUser.FixedTermEndDate = Convert.ToDateTime(FixedTermEndDateToString.ToString(outputFormat)); } AddUser.NoticePeriod = model.NoticePeriodID; AddUser.MethodofRecruitmentSetup = model.MethodofRecruitmentSetup; AddUser.RecruitmentCost = model.RecruitmentCost.ToString(); // AddUser.CurrenciesId = model.curruncyID; if (model.HolidaysThisYear != null) { AddUser.Thisyear = (int)model.HolidaysThisYear; } if (model.HolidaysNextYear != null) { AddUser.Nextyear = (int)model.HolidaysNextYear; } if (model.IncludePublicHoliday != null) { if (model.IncludePublicHoliday == "on") { AddUser.IncludePublicHoliday = true; } else { AddUser.IncludePublicHoliday = false; } } if (model.HolidayEntit != 0 && model.HolidayEntit != null) { AddUser.HolidayEntitlement = model.HolidayEntit; } //step 4 //AddUser.Country = model.CountryId; //AddUser.State = model.StateId; //AddUser.Town = model.CityyId; //AddUser.Airport = model.AirportId; //AddUser.Postcode = model.PostalCode; //AddUser.BankAddress = model.Address; AddUser.WorkPhone = model.WorkPhone; AddUser.WorkMobile = model.WorkMobile; //AddUser.PersonalPhone = model.PersonalPhone; //AddUser.PersonalMobile = model.PersonalMobile; //AddUser.PersonalEmail = model.PersonalEmail; //AddUser.BankName = model.BankName; //AddUser.BankCode = model.BankCode; //AddUser.AccountNumber = model.AccountNumber; //AddUser.OtherAccountInformation = model.OtherAccountInformation; //AddUser.AccountName = model.AccountName; //AddUser.BankAddress = model.BankAddress; AddUser.CreatedBy = model.CurrentUserId; //Step 5 JavaScriptSerializer js = new JavaScriptSerializer(); List <AddnewtaskRecordmodel> listValueArray = js.Deserialize <List <AddnewtaskRecordmodel> >(model.JsonNewtaskList); foreach (var item in listValueArray) { Task_List ModelNew = new Task_List(); ModelNew.InRelationTo = model.Id; ModelNew.Title = item.Title; ModelNew.Description = item.Description; ModelNew.AssignTo = item.Assign; ModelNew.Archived = false; ModelNew.AlterBeforeDays = item.AlertBeforeDays; if (item.DueDate != "") { var DueDateToString = DateTime.ParseExact(item.DueDate, inputFormat, CultureInfo.InvariantCulture); ModelNew.DueDate = Convert.ToDateTime(DueDateToString.ToString(outputFormat)); } ModelNew.Status = item.Status; ModelNew.LastModified = DateTime.Now; ModelNew.Created = DateTime.Now; _db.Task_List.Add(ModelNew); } _db.AspNetUsers.Add(AddUser); _db.SaveChanges(); if (AddUser.Id > 0) { //Employee Relation EmployeeRelation _employeeRelation = new EmployeeRelation(); _employeeRelation.UserID = AddUser.Id; if (model.Reportsto != null) { _employeeRelation.Reportsto = model.Reportsto.Value; } _employeeRelation.BusinessID = model.BusinessID; _employeeRelation.DivisionID = model.DivisionID; _employeeRelation.PoolID = model.PoolID; _employeeRelation.FunctionID = model.FunctionID; _employeeRelation.CreateBy = model.CurrentUserId; _employeeRelation.CreatedDate = DateTime.Now; _employeeRelation.IsActive = true; _db.EmployeeRelations.Add(_employeeRelation); //Employee Address Info EmployeeAddressInfo _EmployeeAddressInfo = new EmployeeAddressInfo(); _EmployeeAddressInfo.UserId = AddUser.Id; _EmployeeAddressInfo.CountryId = model.CountryId; _EmployeeAddressInfo.StateId = model.StateId; _EmployeeAddressInfo.TownId = model.CityyId; _EmployeeAddressInfo.AirportId = model.AirportId; _EmployeeAddressInfo.PostCode = model.PostalCode; _EmployeeAddressInfo.ContactAddress = model.Address; _EmployeeAddressInfo.PersonalPhone = model.PersonalPhone; _EmployeeAddressInfo.PersonalMobile = model.PersonalMobile; _EmployeeAddressInfo.PersonalEmail = model.PersonalEmail; _db.EmployeeAddressInfoes.Add(_EmployeeAddressInfo); EmployeeBankInfo _EmployeeBankInfo = new EmployeeBankInfo(); _EmployeeBankInfo.UserId = AddUser.Id; _EmployeeBankInfo.BankName = model.BankName; _EmployeeBankInfo.BankCode = model.BankCode; _EmployeeBankInfo.AccountName = model.AccountName; _EmployeeBankInfo.AccountNumber = model.AccountNumber; _EmployeeBankInfo.OtherAccountInformation = model.OtherAccountInformation; _EmployeeBankInfo.BankAddress = model.BankAddress; _EmployeeBankInfo.IBAN_No = model.IBAN_Number; _EmployeeBankInfo.SWIFT_Code = model.SWIFT_Code; _db.EmployeeBankInfoes.Add(_EmployeeBankInfo); } if (model.ApplicantID != 0 && model.ApplicantID != null) { var AccepteID = _AdminTMSMethod.GetAcceptedStepId((int)model.ApplicantID); var data = _db.TMS_Applicant.Where(x => x.Id == model.ApplicantID).FirstOrDefault(); data.Archived = true; data.StatusID = AccepteID; data.LastModified = DateTime.Now; } _db.SaveChanges(); return(AddUser.Id); }
public virtual long GetRelationWorld(long emplid, DateTime date) { EmployeeRelation relation = GetRelationEntity(emplid, date); return((relation != null)? relation.WorldID.Value : 0L); }