public async Task ShouldInsert_ExternalAgentAndEmployee() { Guid id = Guid.NewGuid(); Employee employee = new Employee ( new ExternalAgent(id, AgentType.Employee), SupervisorId.Create(id), PersonName.Create("George", "Orwell", "J"), SSN.Create("623789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); await _employeeRepo.AddAsync(employee); await _unitOfWork.Commit(); var employeeResult = await _employeeRepo.Exists(employee.Id); Assert.True(employeeResult); }
public void Configure(EntityTypeBuilder <Employee> entity) { entity.ToTable("Employees", schema: "HumanResources"); entity.HasKey(e => e.Id); entity.Property(p => p.Id).HasColumnType("UNIQUEIDENTIFIER").HasColumnName("EmployeeId"); entity.Property(p => p.SupervisorId) .HasConversion(p => p.Value, p => SupervisorId.Create(p)) .HasColumnType("UNIQUEIDENTIFIER") .HasColumnName("SupervisorId") .IsRequired(); entity.OwnsOne(p => p.EmployeeName, p => { p.Property(pp => pp.LastName).HasColumnType("NVARCHAR(25)").HasColumnName("LastName").IsRequired(); p.Property(pp => pp.FirstName).HasColumnType("NVARCHAR(25)").HasColumnName("FirstName").IsRequired(); p.Property(pp => pp.MiddleInitial).HasColumnType("NCHAR(1)").HasColumnName("MiddleInitial"); }); entity.Property(p => p.SSN) .HasConversion(p => p.Value, p => SSN.Create(p)) .HasColumnType("NVARCHAR(9)") .HasColumnName("SSN") .IsRequired(); entity.Property(p => p.Telephone) .HasConversion(p => p.Value, p => PhoneNumber.Create(p)) .HasColumnType("NVARCHAR(14)") .HasColumnName("Telephone") .IsRequired(); entity.Property(p => p.MaritalStatus) .HasConversion(p => p.Value, p => MaritalStatus.Create(p)) .HasColumnType("NCHAR(1)") .HasColumnName("MaritalStatus") .IsRequired(); entity.Property(p => p.TaxExemption) .HasConversion(p => p.Value, p => TaxExemption.Create(p)) .HasColumnType("int") .HasColumnName("Exemptions") .IsRequired(); entity.Property(p => p.PayRate) .HasConversion(p => p.Value, p => PayRate.Create(p)) .HasColumnType("DECIMAL(18,2)") .HasColumnName("PayRate") .IsRequired(); entity.Property(p => p.StartDate) .HasConversion(p => p.Value, p => StartDate.Create(p)) .HasColumnType("datetime2(0)") .HasColumnName("StartDate") .IsRequired(); entity.Property(p => p.IsActive) .HasConversion(p => p.Value, p => IsActive.Create(p)) .HasColumnType("BIT") .HasColumnName("IsActive") .IsRequired(); entity.Property(e => e.CreatedDate) .HasColumnType("datetime2(7)") .ValueGeneratedOnAdd() .HasDefaultValueSql("sysdatetime()"); entity.Property(e => e.LastModifiedDate).HasColumnType("datetime2(7)"); }
public void ShouldReturn_Valid_EmployeePayRate() { decimal rate = 7.51M; var result = PayRate.Create(rate); Assert.IsType <PayRate>(result); Assert.Equal(rate, result.Value); }
private void SalaryStandardTreeList_Load(object sender, EventArgs e) { CreateWaitDialog("正在加载数据...", "请稍等"); treeList1.ParentFieldName = "父节点标识"; treeList1.DataSource = PayRate.GetAll(); treeList1.ExpandAll(); CloseWaitDialog(); }
public void ShouldRaiseError_Invalid_PayRateTooLarge() { decimal rate = 40.01M; Action action = () => PayRate.Create(rate); var caughtException = Assert.Throws <ArgumentException>(action); Assert.Contains("Invalid pay rate, must be between $7.50 and $40.00 (per hour) inclusive!", caughtException.Message); }
public void ShouldRaiseError_Invalid_PayRateZero() { decimal rate = 0; Action action = () => PayRate.Create(rate); var caughtException = Assert.Throws <ArgumentException>(action); Assert.Contains("Invalid pay rate; pay rate can not be zero!", caughtException.Message); }
public void AddPayRate(PayRateModel payRate) { if (payRate != null) { PayRate newPayRate = new PayRate() { CompanionRate = payRate.CompanionRate, PatientRate = payRate.PatientRate }; _domainObjectRepository.Create <PayRate>(newPayRate); } }
/// <summary> /// records an entry in a specified time sheet /// </summary> /// <param name="timeSheet">the time sheet</param> /// <param name="hours">the number of hours to record</param> /// <param name="payRate">payrate enumerated value</param> public void RecordTime(ITimeSheet timeSheet, int hours, PayRate payRate) { if (payRate == PayRate.Holiday) { timeSheet.AddEntry(name, hours * 3); } else if (payRate == PayRate.Weekend) { timeSheet.AddEntry(name, hours * 2); } else { timeSheet.AddEntry(name, hours); } }
/** Helper methods **/ private Employee GetEmployee() { var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee); return(new Employee ( employeeAgent, SupervisorId.Create(Guid.NewGuid()), PersonName.Create("George", "Orwell", "Z"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) )); }
private DomainUser GetUser() { var agent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee); Employee employee = new Employee ( agent, SupervisorId.Create(agent.Id), PersonName.Create("Ken", "Sanchez", "J"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); return(new DomainUser(agent.Id, "Jon", "Doe", "")); }
public void ShouldReturn_NewEmployee() { var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee); Employee employee = new Employee ( employeeAgent, SupervisorId.Create(employeeAgent.Id), PersonName.Create("Ken", "Sanchez", "J"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); Assert.IsType <Employee>(employee); }
public void ShouldRaiseError_CreateEmployeeWithNullExternalAgent() { Action action = () => new Employee ( null, SupervisorId.Create(Guid.NewGuid()), PersonName.Create("Ken", "Sanchez", "J"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); var caughtException = Assert.Throws <ArgumentNullException>(action); Assert.Contains("The external agent is required.", caughtException.Message); }
private Employee GetEmployeeWithContactPeople() { var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee); var employee = new Employee ( employeeAgent, SupervisorId.Create(Guid.NewGuid()), PersonName.Create("George", "Orwell", "Z"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); employee.AddContactPerson(1, PersonName.Create("Fidel", "Castro", "C"), PhoneNumber.Create("555-555-1234"), "You are being tested."); employee.AddContactPerson(2, PersonName.Create("Fidel", "Raul", "Z"), PhoneNumber.Create("555-555-5678"), "You are not being tested."); return(employee); }
private Employee GetEmployeeWithAddresses() { var employeeAgent = new ExternalAgent(Guid.NewGuid(), AgentType.Employee); var employee = new Employee ( employeeAgent, SupervisorId.Create(Guid.NewGuid()), PersonName.Create("George", "Orwell", "Z"), SSN.Create("123789999"), PhoneNumber.Create("817-987-1234"), MaritalStatus.Create("M"), TaxExemption.Create(5), PayRate.Create(40.00M), StartDate.Create(new DateTime(1998, 12, 2)), IsActive.Create(true) ); employee.AddAddress(1, AddressVO.Create("123 Main Terrace", "#4", "Somewhere", "TX", "78885")); employee.AddAddress(2, AddressVO.Create("123 Main Plaza", "Apt 13", "nowhere", "TX", "78981")); return(employee); }
public void GetEmployeePayRate(Employee employee) { var payrate = new PayRate(); var context = new PayohteeDbContext(null); try { //var employeeresult = context.DbContextCustomsOfficers.Find(employee.EmployeeId); //if (employeeresult == null) //{ // this.PayRate = 0; //} //else //{ // var rateresult = context.DbContextCustomsRate.Where(x => x.RateCode == employeeresult.RateCode).Single(); // this.PayRate = rateresult.RateAmount; //} } catch (Exception e) { Console.WriteLine(e); throw; } }
internal override void resetParentsChildren() { // TODO: for parents null through if (Attendances != null) { foreach (var child in Attendances) { child.resetParentsChildren(); } } if (Entrys != null) { foreach (var child in Entrys) { child.resetParentsChildren(); } } if (EnteredByEntrys != null) { foreach (var child in EnteredByEntrys) { child.resetParentsChildren(); } } if (EnteredByEntrySubtasks != null) { foreach (var child in EnteredByEntrySubtasks) { child.resetParentsChildren(); } } if (EnteredByInventoryTransactions != null) { foreach (var child in EnteredByInventoryTransactions) { child.resetParentsChildren(); } } if (ApprovedDeniedByLeaveRequests != null) { foreach (var child in ApprovedDeniedByLeaveRequests) { child.resetParentsChildren(); } } if (LeaveRequests != null) { foreach (var child in LeaveRequests) { child.resetParentsChildren(); } } if (AssignedToMaintenanceRequests != null) { foreach (var child in AssignedToMaintenanceRequests) { child.resetParentsChildren(); } } if (RequestedByMaintenanceRequests != null) { foreach (var child in RequestedByMaintenanceRequests) { child.resetParentsChildren(); } } if (Schedules != null) { foreach (var child in Schedules) { child.resetParentsChildren(); } } if (TradeUserScheduleTrades != null) { foreach (var child in TradeUserScheduleTrades) { child.resetParentsChildren(); } } if (ApprovedDeniedByUserAvailabilitys != null) { foreach (var child in ApprovedDeniedByUserAvailabilitys) { child.resetParentsChildren(); } } if (UserAvailabilitys != null) { foreach (var child in UserAvailabilitys) { child.resetParentsChildren(); } } if (UserClocks != null) { foreach (var child in UserClocks) { child.resetParentsChildren(); } } if (UserComments != null) { foreach (var child in UserComments) { child.resetParentsChildren(); } } if (UserNotes != null) { foreach (var child in UserNotes) { child.resetParentsChildren(); } } if (UserProgressChecklists != null) { foreach (var child in UserProgressChecklists) { child.resetParentsChildren(); } } if (ManagerUserProgressChecklists != null) { foreach (var child in ManagerUserProgressChecklists) { child.resetParentsChildren(); } } if (CompletedByUserProgressItems != null) { foreach (var child in CompletedByUserProgressItems) { child.resetParentsChildren(); } } if (UserTaskQueues != null) { foreach (var child in UserTaskQueues) { child.resetParentsChildren(); } } _CellPhoneCarrier = null; _Company = null; _PayRate = null; _Position = null; }
/// <summary> /// records an entry in a specified time sheet /// </summary> /// <param name="hours">the number of hours to record</param> /// <param name="payRate">payrate enumerated value</param> public void RecordTime( int hours, PayRate payRate) { throw new NotImplementedException(); }
private static SubTotals CalculateSubTotals(WorkingHours workingHours, DaysOff daysOff, PayRate payRate) { var payForHours = workingHours.Hours * payRate.HourRate; var payForBusinessTrip = workingHours.HourOnBusinessTrip * payRate.BusinessTripHourRate; var payForExtraHours = workingHours.ExtraHours * payRate.ExtraHourRate; var payForHolidayHours = workingHours.HourOnHolidays * payRate.HoidayHourRate; var payForPayedDaysOff = daysOff.PaidDaysOff * (payRate.HourRate * 8); return(ValueObjects.SubTotals.Create(payForHours, payForBusinessTrip, payForExtraHours, payForHolidayHours, payForPayedDaysOff)); }
/// <summary> /// 增加一条数据 /// </summary> public static int Add(PayRate model) { try { SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@rateType", SqlDbType.TinyInt, 1), new SqlParameter("@userLevel", SqlDbType.Int, 4), new SqlParameter("@levName", SqlDbType.VarChar, 50), new SqlParameter("@p100", SqlDbType.Decimal, 9), new SqlParameter("@p101", SqlDbType.Decimal, 9), new SqlParameter("@p102", SqlDbType.Decimal, 9), new SqlParameter("@p103", SqlDbType.Decimal, 9), new SqlParameter("@p104", SqlDbType.Decimal, 9), new SqlParameter("@p105", SqlDbType.Decimal, 9), new SqlParameter("@p106", SqlDbType.Decimal, 9), new SqlParameter("@p107", SqlDbType.Decimal, 9), new SqlParameter("@p108", SqlDbType.Decimal, 9), new SqlParameter("@p109", SqlDbType.Decimal, 9), new SqlParameter("@p110", SqlDbType.Decimal, 9), new SqlParameter("@p111", SqlDbType.Decimal, 9), new SqlParameter("@p112", SqlDbType.Decimal, 9), new SqlParameter("@p113", SqlDbType.Decimal, 9), new SqlParameter("@p114", SqlDbType.Decimal, 9), new SqlParameter("@p115", SqlDbType.Decimal, 9), new SqlParameter("@p116", SqlDbType.Decimal, 9), new SqlParameter("@p117", SqlDbType.Decimal, 9), new SqlParameter("@p118", SqlDbType.Decimal, 9), new SqlParameter("@p119", SqlDbType.Decimal, 9), new SqlParameter("@p300", SqlDbType.Decimal, 9), new SqlParameter("@p200", SqlDbType.Decimal, 9), new SqlParameter("@p201", SqlDbType.Decimal, 9), new SqlParameter("@p202", SqlDbType.Decimal, 9), new SqlParameter("@p203", SqlDbType.Decimal, 9), new SqlParameter("@p204", SqlDbType.Decimal, 9), new SqlParameter("@p205", SqlDbType.Decimal, 9), new SqlParameter("@p207", SqlDbType.Decimal, 9), new SqlParameter("@p208", SqlDbType.Decimal, 9), new SqlParameter("@p209", SqlDbType.Decimal, 9), new SqlParameter("@p210", SqlDbType.Decimal, 9), new SqlParameter("@p206", SqlDbType.Decimal, 9) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.rateType; parameters[2].Value = model.userLevel; parameters[3].Value = model.levName; parameters[4].Value = model.p100; parameters[5].Value = model.p101; parameters[6].Value = model.p102; parameters[7].Value = model.p103; parameters[8].Value = model.p104; parameters[9].Value = model.p105; parameters[10].Value = model.p106; parameters[11].Value = model.p107; parameters[12].Value = model.p108; parameters[13].Value = model.p109; parameters[14].Value = model.p110; parameters[15].Value = model.p111; parameters[16].Value = model.p112; parameters[17].Value = model.p113; parameters[18].Value = model.p114; parameters[19].Value = model.p115; parameters[20].Value = model.p116; parameters[21].Value = model.p117; parameters[22].Value = model.p118; parameters[23].Value = model.p119; parameters[24].Value = model.p300; parameters[25].Value = model.p200; parameters[26].Value = model.p201; parameters[27].Value = model.p202; parameters[28].Value = model.p203; parameters[29].Value = model.p204; parameters[30].Value = model.p205; parameters[31].Value = model.p207; parameters[32].Value = model.p208; parameters[33].Value = model.p209; parameters[34].Value = model.p210; parameters[35].Value = model.p206; int rows = DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "proc_payrate_add", parameters); if (rows > 0) { int modelid = (int)parameters[0].Value; return(modelid); } return(0); } catch (Exception ex) { ExceptionHandler.HandleException(ex); return(0); } }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool Update(PayRate model) { try { SqlParameter[] parameters = { new SqlParameter("@rateType", SqlDbType.TinyInt, 1), new SqlParameter("@userLevel", SqlDbType.Int, 4), new SqlParameter("@levName", SqlDbType.VarChar, 50), new SqlParameter("@p100", SqlDbType.Decimal, 9), new SqlParameter("@p101", SqlDbType.Decimal, 9), new SqlParameter("@p102", SqlDbType.Decimal, 9), new SqlParameter("@p103", SqlDbType.Decimal, 9), new SqlParameter("@p104", SqlDbType.Decimal, 9), new SqlParameter("@p105", SqlDbType.Decimal, 9), new SqlParameter("@p106", SqlDbType.Decimal, 9), new SqlParameter("@p107", SqlDbType.Decimal, 9), new SqlParameter("@p108", SqlDbType.Decimal, 9), new SqlParameter("@p109", SqlDbType.Decimal, 9), new SqlParameter("@p110", SqlDbType.Decimal, 9), new SqlParameter("@p111", SqlDbType.Decimal, 9), new SqlParameter("@p112", SqlDbType.Decimal, 9), new SqlParameter("@p113", SqlDbType.Decimal, 9), new SqlParameter("@p114", SqlDbType.Decimal, 9), new SqlParameter("@p115", SqlDbType.Decimal, 9), new SqlParameter("@p116", SqlDbType.Decimal, 9), new SqlParameter("@p117", SqlDbType.Decimal, 9), new SqlParameter("@p118", SqlDbType.Decimal, 9), new SqlParameter("@p119", SqlDbType.Decimal, 9), new SqlParameter("@p300", SqlDbType.Decimal, 9), new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@p200", SqlDbType.Decimal, 9), new SqlParameter("@p201", SqlDbType.Decimal, 9), new SqlParameter("@p202", SqlDbType.Decimal, 9), new SqlParameter("@p203", SqlDbType.Decimal, 9), new SqlParameter("@p204", SqlDbType.Decimal, 9), new SqlParameter("@p205", SqlDbType.Decimal, 9), new SqlParameter("@p207", SqlDbType.Decimal, 9), new SqlParameter("@p208", SqlDbType.Decimal, 9), new SqlParameter("@p209", SqlDbType.Decimal, 9), new SqlParameter("@p210", SqlDbType.Decimal, 9), new SqlParameter("@p206", SqlDbType.Decimal, 9) }; parameters[0].Value = (int)model.rateType; parameters[1].Value = model.userLevel; parameters[2].Value = model.levName; parameters[3].Value = model.p100; parameters[4].Value = model.p101; parameters[5].Value = model.p102; parameters[6].Value = model.p103; parameters[7].Value = model.p104; parameters[8].Value = model.p105; parameters[9].Value = model.p106; parameters[10].Value = model.p107; parameters[11].Value = model.p108; parameters[12].Value = model.p109; parameters[13].Value = model.p110; parameters[14].Value = model.p111; parameters[15].Value = model.p112; parameters[16].Value = model.p113; parameters[17].Value = model.p114; parameters[18].Value = model.p115; parameters[19].Value = model.p116; parameters[20].Value = model.p117; parameters[21].Value = model.p118; parameters[22].Value = model.p119; parameters[23].Value = model.p300; parameters[24].Value = model.id; parameters[25].Value = model.p200; parameters[26].Value = model.p201; parameters[27].Value = model.p202; parameters[28].Value = model.p203; parameters[29].Value = model.p204; parameters[30].Value = model.p205; parameters[31].Value = model.p207; parameters[32].Value = model.p208; parameters[33].Value = model.p209; parameters[34].Value = model.p210; parameters[35].Value = model.p206; int rows = DataBase.ExecuteNonQuery(CommandType.StoredProcedure, "proc_payrate_Update", parameters); if (rows > 0) { string cacheKey = string.Format(PAYRATEFACTORY_CACHEKEY, (int)model.rateType, model.userLevel); viviapi.Cache.WebCache.GetCacheService().RemoveObject(cacheKey); return(true); } else { return(false); } } catch (Exception ex) { ExceptionHandler.HandleException(ex); return(false); } }
public static async Task Execute(EditEmployeeInfo model, IEmployeeAggregateRepository repo, IUnitOfWork unitOfWork) { var employee = await repo.GetByIdAsync(model.Id) ?? throw new InvalidOperationException($"An employee with id '{model.Id}' could not be found!"); if (model.Status == RecordStatus.Modified) { employee.UpdateSupervisorId(SupervisorId.Create(model.SupervisorId)); employee.UpdateEmployeeName(PersonName.Create(model.FirstName, model.LastName, model.MiddleInitial)); employee.UpdateSSN(SSN.Create(model.SSN)); employee.UpdateTelephone(PhoneNumber.Create(model.Telephone)); employee.UpdateMaritalStatus(MaritalStatus.Create(model.MaritalStatus)); employee.UpdateTaxExemptions(TaxExemption.Create(model.Exemptions)); employee.UpdatePayRate(PayRate.Create(model.PayRate)); employee.UpdateLastModifiedDate(); if (model.IsActive) { employee.Activate(); } else if (!model.IsActive) { employee.Deactivate(); } } if (model.Addresses != null && model.Addresses.Count > 0) { foreach (var address in model.Addresses) { if (address.Status == RecordStatus.New) { employee.AddAddress(0, AddressVO.Create(address.AddressLine1, address.AddressLine2, address.City, address.StateCode, address.Zipcode)); } else if (address.Status == RecordStatus.Modified) { employee.UpdateAddress(address.AddressId, AddressVO.Create(address.AddressLine1, address.AddressLine2, address.City, address.StateCode, address.Zipcode)); } else if (address.Status == RecordStatus.Deleted) { employee.DeleteAddress(address.AddressId); } } } if (model.Contacts != null && model.Contacts.Count > 0) { foreach (var contact in model.Contacts) { if (contact.Status == RecordStatus.New) { employee.AddContactPerson(0, PersonName.Create(contact.FirstName, contact.LastName, contact.MiddleInitial), PhoneNumber.Create(contact.Telephone), contact.Notes); } else if (contact.Status == RecordStatus.Modified) { employee.UpdateContactPerson(contact.PersonId, PersonName.Create(contact.FirstName, contact.LastName, contact.MiddleInitial), PhoneNumber.Create(contact.Telephone), contact.Notes); } if (contact.Status == RecordStatus.Deleted) { employee.DeleteContactPerson(contact.PersonId); } } } await unitOfWork.Commit(); }
public static Paycheck Create( DateTime date, Period period, WorkingHours workingHours, DaysOff daysOff, PayRate payRate, string employeeId) { var subTotal = CalculateSubTotals(workingHours, daysOff, payRate); return(new Paycheck() { Date = date, Period = period, WorkingHours = workingHours, DaysOff = daysOff, PayRate = payRate, SubTotals = subTotal, Total = CalculateTotal(subTotal), IsPaied = false, EmployeeId = employeeId }); }
public static async Task Execute(CreateEmployeeInfo model, IEmployeeAggregateRepository repo, IUnitOfWork unitOfWork) { if (await repo.Exists(model.Id)) { throw new InvalidOperationException($"This employee ({model.FirstName} {model.MiddleInitial ?? ""} {model.LastName}) already exists!"); } ExternalAgent agent = new(model.Id, AgentType.Employee); Employee employee = new Employee ( agent, SupervisorId.Create(model.SupervisorId), PersonName.Create(model.FirstName, model.LastName, model.MiddleInitial), SSN.Create(model.SSN), PhoneNumber.Create(model.Telephone), MaritalStatus.Create(model.MaritalStatus), TaxExemption.Create(model.Exemptions), PayRate.Create(model.PayRate), StartDate.Create(model.StartDate), IsActive.Create(model.IsActive) ); if (model.Addresses != null && model.Addresses.Count > 0) { foreach (var address in model.Addresses) { employee.AddAddress( 0, AddressVO.Create ( address.AddressLine1, address.AddressLine2, address.City, address.StateCode, address.Zipcode ) ); } } if (model.Contacts != null && model.Contacts.Count > 0) { foreach (var contact in model.Contacts) { employee.AddContactPerson ( 0, PersonName.Create(contact.FirstName, contact.LastName, contact.MiddleInitial), PhoneNumber.Create(contact.Telephone), contact.Notes ); } } await repo.AddAsync(employee); await unitOfWork.Commit(); model.Id = employee.Id; }
/// <summary> /// 得到一个对象实体 /// </summary> public static PayRate GetModelByUser(int userid) { SqlParameter[] parameters = { new SqlParameter("@userid", SqlDbType.Int, 4) }; parameters[0].Value = userid; PayRate model = new PayRate(); DataSet ds = DataBase.ExecuteDataset(CommandType.StoredProcedure, "proc_payrate_GetModelByUser", parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["rateType"] != null && ds.Tables[0].Rows[0]["rateType"].ToString() != "") { model.rateType = (RateTypeEnum)int.Parse(ds.Tables[0].Rows[0]["rateType"].ToString()); } if (ds.Tables[0].Rows[0]["userLevel"] != null && ds.Tables[0].Rows[0]["userLevel"].ToString() != "") { model.userLevel = int.Parse(ds.Tables[0].Rows[0]["userLevel"].ToString()); } if (ds.Tables[0].Rows[0]["levName"] != null && ds.Tables[0].Rows[0]["levName"].ToString() != "") { model.levName = ds.Tables[0].Rows[0]["levName"].ToString(); } if (ds.Tables[0].Rows[0]["p100"] != null && ds.Tables[0].Rows[0]["p100"].ToString() != "") { model.p100 = decimal.Parse(ds.Tables[0].Rows[0]["p100"].ToString()); } if (ds.Tables[0].Rows[0]["p101"] != null && ds.Tables[0].Rows[0]["p101"].ToString() != "") { model.p101 = decimal.Parse(ds.Tables[0].Rows[0]["p101"].ToString()); } if (ds.Tables[0].Rows[0]["p102"] != null && ds.Tables[0].Rows[0]["p102"].ToString() != "") { model.p102 = decimal.Parse(ds.Tables[0].Rows[0]["p102"].ToString()); } if (ds.Tables[0].Rows[0]["p103"] != null && ds.Tables[0].Rows[0]["p103"].ToString() != "") { model.p103 = decimal.Parse(ds.Tables[0].Rows[0]["p103"].ToString()); } if (ds.Tables[0].Rows[0]["p104"] != null && ds.Tables[0].Rows[0]["p104"].ToString() != "") { model.p104 = decimal.Parse(ds.Tables[0].Rows[0]["p104"].ToString()); } if (ds.Tables[0].Rows[0]["p105"] != null && ds.Tables[0].Rows[0]["p105"].ToString() != "") { model.p105 = decimal.Parse(ds.Tables[0].Rows[0]["p105"].ToString()); } if (ds.Tables[0].Rows[0]["p106"] != null && ds.Tables[0].Rows[0]["p106"].ToString() != "") { model.p106 = decimal.Parse(ds.Tables[0].Rows[0]["p106"].ToString()); } if (ds.Tables[0].Rows[0]["p107"] != null && ds.Tables[0].Rows[0]["p107"].ToString() != "") { model.p107 = decimal.Parse(ds.Tables[0].Rows[0]["p107"].ToString()); } if (ds.Tables[0].Rows[0]["p108"] != null && ds.Tables[0].Rows[0]["p108"].ToString() != "") { model.p108 = decimal.Parse(ds.Tables[0].Rows[0]["p108"].ToString()); } if (ds.Tables[0].Rows[0]["p109"] != null && ds.Tables[0].Rows[0]["p109"].ToString() != "") { model.p109 = decimal.Parse(ds.Tables[0].Rows[0]["p109"].ToString()); } if (ds.Tables[0].Rows[0]["p110"] != null && ds.Tables[0].Rows[0]["p110"].ToString() != "") { model.p110 = decimal.Parse(ds.Tables[0].Rows[0]["p110"].ToString()); } if (ds.Tables[0].Rows[0]["p111"] != null && ds.Tables[0].Rows[0]["p111"].ToString() != "") { model.p111 = decimal.Parse(ds.Tables[0].Rows[0]["p111"].ToString()); } if (ds.Tables[0].Rows[0]["p112"] != null && ds.Tables[0].Rows[0]["p112"].ToString() != "") { model.p112 = decimal.Parse(ds.Tables[0].Rows[0]["p112"].ToString()); } if (ds.Tables[0].Rows[0]["p113"] != null && ds.Tables[0].Rows[0]["p113"].ToString() != "") { model.p113 = decimal.Parse(ds.Tables[0].Rows[0]["p113"].ToString()); } if (ds.Tables[0].Rows[0]["p114"] != null && ds.Tables[0].Rows[0]["p114"].ToString() != "") { model.p114 = decimal.Parse(ds.Tables[0].Rows[0]["p114"].ToString()); } if (ds.Tables[0].Rows[0]["p115"] != null && ds.Tables[0].Rows[0]["p115"].ToString() != "") { model.p115 = decimal.Parse(ds.Tables[0].Rows[0]["p115"].ToString()); } if (ds.Tables[0].Rows[0]["p116"] != null && ds.Tables[0].Rows[0]["p116"].ToString() != "") { model.p116 = decimal.Parse(ds.Tables[0].Rows[0]["p116"].ToString()); } if (ds.Tables[0].Rows[0]["p117"] != null && ds.Tables[0].Rows[0]["p117"].ToString() != "") { model.p117 = decimal.Parse(ds.Tables[0].Rows[0]["p117"].ToString()); } if (ds.Tables[0].Rows[0]["p118"] != null && ds.Tables[0].Rows[0]["p118"].ToString() != "") { model.p118 = decimal.Parse(ds.Tables[0].Rows[0]["p118"].ToString()); } if (ds.Tables[0].Rows[0]["p119"] != null && ds.Tables[0].Rows[0]["p119"].ToString() != "") { model.p119 = decimal.Parse(ds.Tables[0].Rows[0]["p119"].ToString()); } if (ds.Tables[0].Rows[0]["p300"] != null && ds.Tables[0].Rows[0]["p300"].ToString() != "") { model.p300 = decimal.Parse(ds.Tables[0].Rows[0]["p300"].ToString()); } if (ds.Tables[0].Rows[0]["p200"] != null && ds.Tables[0].Rows[0]["p200"].ToString() != "") { model.p200 = decimal.Parse(ds.Tables[0].Rows[0]["p200"].ToString()); } if (ds.Tables[0].Rows[0]["p201"] != null && ds.Tables[0].Rows[0]["p201"].ToString() != "") { model.p201 = decimal.Parse(ds.Tables[0].Rows[0]["p201"].ToString()); } if (ds.Tables[0].Rows[0]["p202"] != null && ds.Tables[0].Rows[0]["p202"].ToString() != "") { model.p202 = decimal.Parse(ds.Tables[0].Rows[0]["p202"].ToString()); } if (ds.Tables[0].Rows[0]["p203"] != null && ds.Tables[0].Rows[0]["p203"].ToString() != "") { model.p203 = decimal.Parse(ds.Tables[0].Rows[0]["p203"].ToString()); } if (ds.Tables[0].Rows[0]["p204"] != null && ds.Tables[0].Rows[0]["p204"].ToString() != "") { model.p204 = decimal.Parse(ds.Tables[0].Rows[0]["p204"].ToString()); } if (ds.Tables[0].Rows[0]["p205"] != null && ds.Tables[0].Rows[0]["p205"].ToString() != "") { model.p205 = decimal.Parse(ds.Tables[0].Rows[0]["p205"].ToString()); } if (ds.Tables[0].Rows[0]["p206"] != null && ds.Tables[0].Rows[0]["p206"].ToString() != "") { model.p206 = decimal.Parse(ds.Tables[0].Rows[0]["p206"].ToString()); } if (ds.Tables[0].Rows[0]["p207"] != null && ds.Tables[0].Rows[0]["p207"].ToString() != "") { model.p207 = decimal.Parse(ds.Tables[0].Rows[0]["p207"].ToString()); } if (ds.Tables[0].Rows[0]["p208"] != null && ds.Tables[0].Rows[0]["p208"].ToString() != "") { model.p208 = decimal.Parse(ds.Tables[0].Rows[0]["p208"].ToString()); } if (ds.Tables[0].Rows[0]["p209"] != null && ds.Tables[0].Rows[0]["p209"].ToString() != "") { model.p209 = decimal.Parse(ds.Tables[0].Rows[0]["p209"].ToString()); } if (ds.Tables[0].Rows[0]["p210"] != null && ds.Tables[0].Rows[0]["p210"].ToString() != "") { model.p210 = decimal.Parse(ds.Tables[0].Rows[0]["p210"].ToString()); } return(model); } else { return(null); } }