private DistributorSalesmanDTO Map(tblCostCentre tbl) { var dto = new DistributorSalesmanDTO { MasterId = tbl.Id, DateCreated = tbl.IM_DateCreated, DateLastUpdated = tbl.IM_DateLastUpdated, StatusId = tbl.IM_Status, Name = tbl.Name, CostCentreCode = tbl.Cost_Centre_Code, ParentCostCentreId = tbl.ParentCostCentreId ?? Guid.Empty, CostCentreTypeId = tbl.CostCentreType ?? 0, RouteMasterId = tbl.RouteId ?? Guid.Empty, VatRegistrationNo = tbl.StandardWH_VatRegistrationNo, Latitude = tbl.StandardWH_Latitude, Longitude = tbl.StandardWH_Longtitude, TypeId = tbl.CostCentreType2, }; return dto; }
private async Task<ImportValidationResultInfo> MapAndValidate(DistributorSalesmanDTO dto, int index) { return await Task.Run(() => { var entity = _mappingService.Map(dto); var exist = _ctx.tblCostCentre.FirstOrDefault(p => p.Cost_Centre_Code.ToLower() == dto.CostCentreCode.ToLower() && p.CostCentreType==(int)CostCentreType.DistributorSalesman); entity.Id = exist == null ? Guid.NewGuid() : exist.Id; var res = _repository.Validate(entity); var vResult = new ImportValidationResultInfo() { Results = res.Results, Description =string.Format("Row-{0} name or code=>{1}", index, entity.Name ?? entity.CostCentreCode), Entity = entity }; return vResult; }); }
public DistributorSalesman Map(DistributorSalesmanDTO dto) { if (dto == null) return null; var distributorSalesman = Mapper.Map<DistributorSalesmanDTO, DistributorSalesman>(dto); var parentCostCentre = new CostCentreRef { Id = dto.ParentCostCentreId }; parentCostCentre.Id = dto.ParentCostCentreId; distributorSalesman.ParentCostCentre = parentCostCentre; distributorSalesman.Type = (DistributorSalesmanType) dto.TypeId; return distributorSalesman; }