/// <summary> /// Modifies a restaurant. /// </summary> /// <param name="r">The modified restaurant.</param> /// <returns>True in case of successful update, false in case of failure.</returns> public bool ModifyRestaurant(Restaurant r) { int nbrRowsUpdated = -1; DataRow row = dp.ds.RESTAURANT.Select(string.Format("RESTAURANTID = '{0}'", r.Id)).FirstOrDefault(); row["NAME"] = r.Name; row["MAIL"] = r.Mail; row["PHONE"] = r.Phone; row["DESCRIPTION"] = r.Description; row["PLACEQUANTITY"] = r.PlaceQuantity; row["DAYOFCLOSING"] = r.DayOfClosing; row["PICTURELOCATION"] = r.PictureLocation; row["ENABLE"] = r.IsEnabled; row["ISPREMIUM"] = r.IsPremium; using (RestoBook.Common.Model.DataSetRestoBookTableAdapters.RESTAURANTTableAdapter daRestaurant = new Model.DataSetRestoBookTableAdapters.RESTAURANTTableAdapter()) { nbrRowsUpdated = daRestaurant.Update(row); } return(nbrRowsUpdated > 0); }
/// <summary> /// Deletes a restaurant. /// </summary> /// <param name="r">The restaurant to delete.</param> /// <returns>True in case of successful update, false in case of failure.</returns> public bool DeleteRestaurant(Restaurant r) { int nbrRowsDeleted = -1; using (RestoBook.Common.Model.DataSetRestoBookTableAdapters.RESTAURANTTableAdapter daRestaurant = new Model.DataSetRestoBookTableAdapters.RESTAURANTTableAdapter()) { nbrRowsDeleted = daRestaurant.Delete(r.Id, r.Owner.Id, r.FoodType.Id, r.Name, r.Mail, r.Phone, r.Description, r.PlaceQuantity, r.DayOfClosing, r.PictureLocation, r.IsEnabled, r.IsPremium); } return(nbrRowsDeleted > 0); }