public IBLL.DTO.EpisodioDTO GetEpisodioById(string id) { Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); IBLL.DTO.EpisodioDTO epis = null; try { IDAL.VO.EpisodioVO dalRes = this.dal.GetEpisodioById(id); epis = EpisodioMapper.EpisMapper(dalRes); log.Info(string.Format("{0} VOs mapped to {1}", LibString.ItemsNumber(epis), LibString.TypeName(epis))); } catch (Exception ex) { string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(epis); }
public IBLL.DTO.EpisodioDTO AddEpisodio(IBLL.DTO.EpisodioDTO data) { Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); IBLL.DTO.EpisodioDTO toReturn = null; try { data.episidid = null; IDAL.VO.EpisodioVO data_ = EpisodioMapper.EpisMapper(data); log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(data_), LibString.TypeName(data), LibString.TypeName(data_))); IDAL.VO.EpisodioVO stored = dal.NewEpisodio(data_); log.Info(string.Format("{0} {1} items added and got back!", LibString.ItemsNumber(stored), LibString.TypeName(stored))); toReturn = EpisodioMapper.EpisMapper(stored); log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(toReturn), LibString.TypeName(stored), LibString.TypeName(toReturn))); } catch (Exception ex) { string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(toReturn); }
static void Main(string[] args) { DataAccessLayer.LISDAL dal = new DataAccessLayer.LISDAL(); BusinessLogicLayer.LISBLL bll = new BusinessLogicLayer.LISBLL(dal); IBLL.DTO.EpisodioDTO epis = bll.GetEpisodioById("697798"); }
public static IBLL.DTO.EpisodioDTO EpisMapper(IDAL.VO.EpisodioVO raw) { IBLL.DTO.EpisodioDTO epis = null; try { Mapper.Initialize(cfg => cfg.CreateMap <IDAL.VO.EpisodioVO, IBLL.DTO.EpisodioDTO>()); Mapper.AssertConfigurationIsValid(); epis = Mapper.Map <IBLL.DTO.EpisodioDTO>(raw); } catch (AutoMapperConfigurationException ex) { log.Error(string.Format("AutoMapper Configuration Error!\n{0}", ex.Message)); } catch (AutoMapperMappingException ex) { log.Error(string.Format("AutoMapper Mapping Error!\n{0}", ex.Message)); } return(epis); }
public IBLL.DTO.EpisodioDTO UpdateEpisodio(IBLL.DTO.EpisodioDTO data) { Stopwatch tw = new Stopwatch(); tw.Start(); log.Info(string.Format("Starting ...")); int stored = 0; IBLL.DTO.EpisodioDTO toReturn = null; string id = data.episidid.ToString(); try { if (id == null || GetEpisodioById(id) == null) { string msg = string.Format("No record found with the id {0}! Updating is impossible!", id); log.Info(msg); log.Error(msg); return(null); } IDAL.VO.EpisodioVO data_ = EpisodioMapper.EpisMapper(data); log.Info(string.Format("{0} {1} mapped to {2}", LibString.ItemsNumber(data_), LibString.TypeName(data), LibString.TypeName(data_))); stored = dal.SetEpisodio(data_); toReturn = GetEpisodioById(id); log.Info(string.Format("{0} {1} items added and {2} {3} retrieved back!", stored, LibString.TypeName(data_), LibString.ItemsNumber(toReturn), LibString.TypeName(toReturn))); } catch (Exception ex) { string msg = "An Error occured! Exception detected!"; log.Info(msg); log.Error(msg + "\n" + ex.Message); } tw.Stop(); log.Info(string.Format("Completed! Elapsed time {0}", LibString.TimeSpanToTimeHmsms(tw.Elapsed))); return(toReturn); }