Exemplo n.º 1
0
        public void Add(IRestaurantModel restaurantModel)
        {
            //throw new NotImplementedException();
            DataAccessStatus dataAccesStatus = new DataAccessStatus();

            using (SQLiteConnection sqLiteConnection = new SQLiteConnection(_connectionString))
            {
                try
                {
                    sqLiteConnection.Open();
                }
                catch (SQLiteException e)
                {
                    dataAccesStatus.setValues(status: "Error", operationSucceded: false, exceptionMessage: e.Message, customMessage: "Unable to open db connection", helpLink: e.HelpLink, errorCode: e.ErrorCode, stackTrace: e.StackTrace);
                    throw new DataAccessException(e.Message, e.InnerException, dataAccesStatus);
                }

                string sql = "INSERT INTO Restaurants (RestaurantAddress, RestaurantName)" +
                             "VALUES (@RestaurantAddress, @RestaurantName)";
                using (SQLiteCommand cmd = new SQLiteCommand(sql, sqLiteConnection))
                {
                    /*try
                     * {
                     *  UserExistsCheck(cmd, userModel, TypeOfExsistenceCheck.DoesNotExistInDB, RequestType.Add)
                     * }*/
                    cmd.CommandText = sql;
                    cmd.Prepare();

                    cmd.Parameters.AddWithValue("@RestaurantAddress", restaurantModel.RestaurantAddress);
                    cmd.Parameters.AddWithValue("@RestaurantName", restaurantModel.RestaurantName);

                    try
                    {
                        cmd.ExecuteNonQuery();
                    }
                    catch (SQLiteException e)
                    {
                        dataAccesStatus.setValues(status: "Error", operationSucceded: false, exceptionMessage: e.Message, customMessage: "Unable to add Restaurant to db", helpLink: e.HelpLink, errorCode: e.ErrorCode, stackTrace: e.StackTrace);
                        throw new DataAccessException(e.Message, e.InnerException, dataAccesStatus);
                    }
                    sqLiteConnection.Close();
                }
            }
        }
Exemplo n.º 2
0
 /// <summary> Ресторан с тремя звездами Мишлена </summary>
 public Michelins3StarsRestaurant(IWaiterFactory waiterFactory, IRestaurantModel restaurantModel)
 {
     _waiterFactory   = waiterFactory;
     _restaurantModel = restaurantModel;
 }
Exemplo n.º 3
0
 public void Update(IRestaurantModel restaurantModel)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
 /// <summary> Подмостовный ресторан </summary>
 public UnderTheBridgeRestaurant(IWaiterFactory waiterFactory, IRestaurantModel restaurantModel)
 {
     _waiterFactory   = waiterFactory;
     _restaurantModel = restaurantModel;
 }
Exemplo n.º 5
0
 public void ValidateModelDataAnnotations(IRestaurantModel restaurantModel)
 {
     _modelDataAnnotationCheck.ValidateModelDataAnnotations(restaurantModel);
 }
Exemplo n.º 6
0
 public void ValidateModel(IRestaurantModel restaurantModel)
 {
     //throw new NotImplementedException();
     _modelDataAnnotationCheck.ValidateModelDataAnnotations(restaurantModel);
 }
Exemplo n.º 7
0
 public void Delete(IRestaurantModel restaurantModel)
 {
     //throw new NotImplementedException();
     _restaurantRepository.Delete(restaurantModel);
 }