public static Models.Resturant DataToModel(DataLayer.Resturant data) { Models.Resturant r = new Models.Resturant(); r.rs_id = data.rs_id; r.Name = data.Name; r.Address = data.Address; r.City = data.City; r.State = data.State; r.FoodType = data.FoodType; r.Reviews = new List <Models.Review>(); foreach (var rev in data.Reviews) { var tmp = new Models.Review { rv_id = rev.rv_id, Author = rev.Author, Rating = rev.Rating, Comment = rev.Comment }; r.Reviews.Add(tmp); } return(r); }
public Models.Resturant GetResturantByID(int id) { List <DataLayer.Resturant> tmp = data.GetResturants().ToList(); List <DataLayer.Resturant> res = tmp.Where(x => x.rs_id == id).ToList(); DataLayer.Resturant dataRes = res.FirstOrDefault(); return(DataToModel(dataRes)); }
public void TestMapping() { Models.Resturant r = new Models.Resturant(); DataLayer.Resturant r1 = new DataLayer.Resturant(); Models.Resturant tmp = DataLayer.DataManager.DataToModel(r1); DataLayer.Resturant tmp1 = DataLayer.DataManager.ModelToData(r); Assert.AreEqual(r.GetType(), tmp.GetType()); Assert.AreEqual(r1.GetType(), tmp1.GetType()); }
//Mapping public static Resturant ModelToData(Models.Resturant model) { DataLayer.Resturant r = new DataLayer.Resturant(); r.Name = model.Name; r.Address = model.Address; r.City = model.City; r.State = model.State; r.FoodType = model.FoodType; foreach (var rev in model.Reviews) { var tmp = new DataLayer.Review { Author = rev.Author, Rating = rev.Rating, Comment = rev.Comment }; r.Reviews.Add(tmp); } return(r); }
public void updateResturant(Models.Resturant modelRes) { DataLayer.Resturant dataRes = ModelToData(modelRes); data.Update(dataRes); }
public void addResturant(Models.Resturant modelRes) { DataLayer.Resturant dataRes = ModelToData(modelRes); data.Add(dataRes); }
public void deleteResturant(Models.Resturant modelRes) { DataLayer.Resturant dataRes = ModelToData(modelRes); data.deleteResturant(dataRes); }