private void UpdateDealPayScheculeFromModel(DealPaySchedule target, DealPayScheduleModel source) { target.DealId = source.DealId; target.DealPayScheduleId = source.DealPayScheduleId; target.Description = source.Description; target.ScheduleDate = source.ScheduleDate.UtcDateTime; target.Amount1 = source.Amount1; target.Amount2 = source.Amount2; }
private void UpdateDealPayScheculeFromModel(DealPaySchedule target, DealPayScheduleModel source) { target.DealId = source.DealId; target.DealPayScheduleId = source.DealPayScheduleId; target.Description = source.Description; target.ScheduleDate = source.ScheduleDate.UtcDateTime; target.Amount1 = Convert.ToDecimal(source.Amount1); target.Amount2 = Convert.ToDecimal(source.Amount2); }
public async Task <int> AddDealAsync(DealModel model) { using (var dataService = DataServiceFactory.CreateDataService()) { var deal = new Deal(); UpdateDealFromModel(deal, model); if (model.DealParties != null && model.DealParties.Count > 0) { var list = new List <DealParties>(); foreach (var obj in model.DealParties) { if (obj.DealPartyId > 0) { continue; } var dealParty = new DealParties(); UpdateDealPartiesFromModel(dealParty, obj); dealParty.DealPartyId = 0; list.Add(dealParty); } deal.DealParties = list; } if (model.DealPaySchedules != null && model.DealPaySchedules.Count > 0) { var list = new List <DealPaySchedule>(); foreach (var obj in model.DealPaySchedules) { if (obj.DealPayScheduleId > 0) { continue; } var pay = new DealPaySchedule(); UpdateDealPayScheculeFromModel(pay, obj); pay.DealPayScheduleId = 0; list.Add(pay); } deal.DealPaySchedules = list; } var dealId = await dataService.AddDealAsync(deal); model.Merge(await GetDealsAsync(dataService, dealId)); return(dealId); } }