public ItemOutputStockFunerary StartMapper(OsProduct osProduct) { var config = new MapperConfiguration(cfg => { cfg.CreateMap <OsProduct, ItemOutputStockFunerary>() .ForMember(x => x.CompanyControl, opt => opt.Ignore()) .ForMember(x => x.CompanyControlId, opt => opt.Ignore()) .ForMember(x => x.DateRegistration, opt => opt.Ignore()) .ForMember(x => x.DateUpdate, opt => opt.Ignore()) .ForMember(x => x.Id, opt => opt.Ignore()) .ForMember(x => x.Integration, opt => opt.Ignore()) .ForMember(x => x.Status, opt => opt.Ignore()) .ForMember(x => x.UserControl, opt => opt.Ignore()) .ForMember(x => x.UserControlId, opt => opt.Ignore()) .ForMember(x => x.OsProductId, opt => opt.MapFrom(x => x.Id)) .ForMember(x => x.TypeIntegration, opt => opt.MapFrom(x => TypeIntegration.OutputStock)) .ForMember(x => x.TypeIntegrationId, opt => opt.MapFrom(x => (int)TypeIntegration.OutputStock)) .ForMember(x => x.LocalStockId, opt => opt.MapFrom(x => x.LocalStockId)) .ForMember(x => x.LocalStockId, opt => opt.MapFrom(x => x.LocalStockId)) .ForMember(x => x.Quantity, opt => opt.MapFrom(x => x.Quantity)) .ForMember(x => x.UnitaryValue, opt => opt.MapFrom(x => x.UnitaryValue)) .ForMember(x => x.Total, opt => opt.MapFrom(x => x.ValueTotal)) .ForMember(x => x.UnitMeasureId, opt => opt.MapFrom(x => x.UnitMeasureId)) .ForMember(x => x.Date, opt => opt.MapFrom(x => DateTime.Now)) .ForMember(x => x.Origin, opt => opt.MapFrom(x => typeof(OsProduct).Name)); }); IMapper mapper = config.CreateMapper(); var obj = mapper.Map <OsProduct, ItemOutputStockFunerary>(osProduct); return(obj); }
public bool Save(OsProduct OsProduct) { _connection.BeginTransaction(); if (_OsProductApp.InsertOrUpdate(OsProduct)) { _connection.Save(); _connection.Commit(); return(true); } else { _connection.Rollback(); return(false); } }
public bool InsertOrUpdate(OsProduct OsProduct) { try { _epr.InsertOrUpdate(OsProduct); return(_conn.Save()); //if (_conn.Save()) //{ // //var os = _osApp.FindId(OsProduct.OrderOfServiceId); // //var mapper = new FuneraryMapper(); // //if (_integrationCapeStockApp.InsertOrUpdate(mapper.StartMapper(os))) // //{ // // var capaId = _integrationCapeStockApp.GetIdStock(c => (c as OutputStockFunerary).OrderOfServiceId == os.Id, Stock.Domain.Integration.TypeIntegration.OutputStock); // // var integrationId = _integrationCapeStockApp.Search(c => (c as OutputStockFunerary).OrderOfServiceId == os.Id).FirstOrDefault().Id; // // var itemIntegration = mapper.StartMapper(OsProduct); // // itemIntegration.IntegrationCapeStockId = integrationId; // // itemIntegration.OutputStockId = capaId; // // return _integrationItemsStockApp.InsertOrUpdate(itemIntegration); // //} //} //return false; } catch (Exception ex) { GlobalUser.Logs.Add(new Log() { ProcessStatus = ProcessStatus.Error, Description = ex.Message }); return(false); } }