private RestaurantTypes GetRestaurantTypeFromReader(SqlDataReader reader) { RestaurantTypes r = new RestaurantTypes() { Type = Convert.ToString(reader["type"]), TypeId = Convert.ToInt32(reader["type_id"]) }; return(r); }
private Restaurants SaveRestaurantOperations(string fileBase64, MultipartFormDataStreamProvider provider) { //get restaurant details model RestaurantDetailsModel model = JsonConvert.DeserializeObject <RestaurantDetailsModel>(provider.FormData[0]); model.RestaurantThumbnail = fileBase64; Restaurants restaurant = new Restaurants() { RestaurantName = model.RestaurantName }; _restaurantOperations.AddRestaurant(ref restaurant); RestaurantAdministrators restAdmin = new RestaurantAdministrators() { RestaurantId = restaurant.RestaurantId, UserID = model.UserId }; _restaurantOperations.SaveRestaurantAdministrator(restAdmin); RestaurantLocations restLoc = new RestaurantLocations() { RestaurantCity = model.RestaurantCity, RestaurantCounty = model.RestaurantCounty, RestaurantAddress = model.RestaurantAddress, RestaurantId = restaurant.RestaurantId }; _restaurantOperations.SaveRestaurantLocation(restLoc); RestaurantDetails restDetails = Mapper.Map <RestaurantDetailsModel, RestaurantDetails>(model); restDetails.RestaurantId = restaurant.RestaurantId; restDetails.RestaurantDirectoryGuid = Path.Combine(HttpContext.Current.Server.MapPath("~/App_Data"), "Restaurant_" + restaurant.RestaurantId); _restaurantOperations.SaveRestaurantDetails(restDetails); RestaurantTypes restType = new RestaurantTypes() { TypeName = RestTypesEnum.RestaurantTypes[model.RestaurantTypeId], RestaurantId = restaurant.RestaurantId }; _restaurantOperations.SaveRestaurantType(restType); return(restaurant); }