//Hàm static public static List <KhoSanPham> DocTatCa() { //Xài automapper var logic = new KhoSanPhamLogic(); var config = new MapperConfiguration(cfg => cfg.CreateMap <KhoSanPhamBDO, KhoSanPham>()); var mapper = config.CreateMapper(); List <KhoSanPham> nguon = mapper.Map <List <KhoSanPhamBDO>, List <KhoSanPham> >(logic.DocTatCa()); return(nguon); }
public static string Sua(KhoSanPham item) { var logic = new KhoSanPhamLogic(); var config = new MapperConfiguration(cfg => cfg.CreateMap <KhoSanPham, KhoSanPhamBDO>()); var mapper = config.CreateMapper(); var objBDO = mapper.Map <KhoSanPhamBDO>(item); logic.Sua(objBDO); return("Sửa xong"); }
//-TODO-- Đổi qua automap không cần #region them, sua public static string Them(KhoSanPham item) { var logic = new KhoSanPhamLogic(); var config = new MapperConfiguration(cfg => cfg.CreateMap <KhoSanPham, KhoSanPhamBDO>()); var mapper = config.CreateMapper(); var objBDO = mapper.Map <KhoSanPhamBDO>(item); //Thêm if (objBDO != null) { logic.Them(objBDO); //Thành công Mapper được } return(""); }
public static KhoSanPham DocTheoId(int iD) { var logic = new KhoSanPhamLogic(); var objBDO = logic.DocTheoId(iD); var config = new MapperConfiguration(cfg => cfg.CreateMap <KhoSanPhamBDO, KhoSanPham>() ); var mapper = config.CreateMapper(); var objModel = mapper.Map <KhoSanPham>(objBDO); //Trả về return(objModel); }