Example #1
0
        /// <summary>
        /// Modifies the information of an customer in the DataBase.
        /// </summary>
        /// <param name="dataBaseCustomer">Customer object in the DataBase.</param>
        /// <param name="modifiedCustomer">Model with the new information of the customer.</param>
        public void UpdateCustomer(Customer dataBaseCustomer, IUpdatable <Customer> modifiedCustomer)
        {
            if (dataBaseCustomer == null)
            {
                throw new ArgumentNullException(nameof(dataBaseCustomer));
            }

            if (modifiedCustomer == null)
            {
                throw new ArgumentNullException(nameof(modifiedCustomer));
            }

            modifiedCustomer.ModifyDataBaseObject(dataBaseCustomer);

            dbContext.SaveChanges();
        }
Example #2
0
        public void UpdateProduct(Product dataBaseProduct, IUpdatable <Product> modifiedProduct)
        {
            if (dataBaseProduct == null)
            {
                throw new ArgumentNullException(nameof(dataBaseProduct));
            }

            if (modifiedProduct == null)
            {
                throw new ArgumentNullException(nameof(modifiedProduct));
            }

            modifiedProduct.ModifyDataBaseObject(dataBaseProduct);

            dbContext.SaveChanges();
        }
Example #3
0
        public void UpdateProduct(int id, IUpdatable <Product> modifiedProduct)
        {
            if (modifiedProduct == null)
            {
                throw new ArgumentNullException(nameof(modifiedProduct));
            }

            Product dataBaseProduct = GetProductById(id);

            if (dataBaseProduct == null)
            {
                throw new KeyNotFoundException();
            }

            modifiedProduct.ModifyDataBaseObject(dataBaseProduct);

            dbContext.SaveChanges();
        }
Example #4
0
        /// <summary>
        /// Modifies the information of an customer in the DataBase.
        /// </summary>
        /// <param name="id">Id of the customer being modified.</param>
        /// <param name="modifiedCustomer">Model with the new information of the customer.</param>
        public void UpdateCustomer(string id, IUpdatable <Customer> modifiedCustomer)
        {
            if (modifiedCustomer == null)
            {
                throw new ArgumentNullException(nameof(modifiedCustomer));
            }

            Customer dataBaseCustomer = GetCustomerById(id);

            if (dataBaseCustomer == null)
            {
                throw new KeyNotFoundException();
            }

            modifiedCustomer.ModifyDataBaseObject(dataBaseCustomer);

            dbContext.SaveChanges();
        }
Example #5
0
        // Actualiza un registro de la Base de Datos. El registro modificado es el que se indica en el ID.
        // La información que se modifica es la que contiene el modelo modifiedCustomer.
        public void UpdateCustomer(string id, IUpdatable <Customer> modifiedCustomer)
        {
            if (modifiedCustomer == null)
            {
                throw new ArgumentNullException(nameof(modifiedCustomer));
            }

            // Obtiene el cliente especificado de la Base de Datos.
            Customer dataBaseCustomer = GetCustomerById(id);

            if (dataBaseCustomer == null)
            {
                throw new KeyNotFoundException();
            }

            // Modifica el cliente obtenido con la información que contiene el modelo.
            modifiedCustomer.ModifyDataBaseObject(dataBaseCustomer);

            // Guarda los cambios.
            dbContext.SaveChanges();
        }
Example #6
0
        // Actualiza un registro de la Base de Datos. El registro modificado es el que se indica en el ID.
        // La información que se modifica es la que contiene el modelo modifiedEmployee.
        public void UpdateEmployee(int id, IUpdatable <Employee> modifiedEmployee)
        {
            if (modifiedEmployee == null)
            {
                throw new ArgumentNullException(nameof(modifiedEmployee));
            }

            // Obtiene el empleado especificado de la Base de Datos.
            Employee dataBaseEmployee = GetEmployeeById(id);

            if (dataBaseEmployee == null)
            {
                throw new KeyNotFoundException();
            }

            // Modifica el empleado obtenido con la información que contiene el modelo.
            modifiedEmployee.ModifyDataBaseObject(dataBaseEmployee);

            // Guarda los cambios.
            dbContext.SaveChanges();
        }
Example #7
0
        // Actualiza un registro de la Base de Datos. El registro modificado es el que se indica en el ID.
        // La información que se modifica es la que contiene el modelo modifiedProduct.
        public void UpdateProduct(int id, IUpdatable <Product> modifiedProduct)
        {
            if (modifiedProduct == null)
            {
                throw new ArgumentNullException(nameof(modifiedProduct));
            }

            // Obtiene el producto especificado de la Base de Datos.
            Product dataBaseProduct = GetProductById(id);

            if (dataBaseProduct == null)
            {
                throw new KeyNotFoundException();
            }

            // Modifica el producto obtenido con la información que contiene el modelo.
            modifiedProduct.ModifyDataBaseObject(dataBaseProduct);

            // Guarda los cambios.
            dbContext.SaveChanges();
        }