public static HomePageBarViewModel MapToHomePageBarVM(this HomePageBarDTO bar) { var homePageBarVM = new HomePageBarViewModel(); homePageBarVM.Id = bar.Id; homePageBarVM.Name = bar.Name; homePageBarVM.City = bar.City; homePageBarVM.ImageUrl = bar.ImageUrl; return(homePageBarVM); }
public static HomePageBarDTO MapBarToHomePageBarDTO(this Bar bar) //tested { var newBarDTO = new HomePageBarDTO(); newBarDTO.Id = bar.Id; newBarDTO.Name = bar.Name; newBarDTO.ImageUrl = bar.Image; try { newBarDTO.City = bar.Address.City; //check if throw if adress not included } catch (Exception) { throw new Exception("Address cannot be null"); } return(newBarDTO); }