Ejemplo n.º 1
0
        /// <summary>
        /// Adds the record to the database
        /// </summary>
        /// <param name="race">A Race model</param>
        public async Task AddAsync(Race race)
        {
            try
            {
                await _context.AddAsync(race);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw;
                // In here we would log the exception and return an error message to the user
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Adds the record to the database
        /// </summary>
        /// <param name="vehicle">A Vehicle model</param>
        public async Task AddAsync(Vehicle vehicle)
        {
            try
            {
                if (string.IsNullOrEmpty(vehicle.VehicleAlias))
                {
                    vehicle.VehicleAlias = vehicle.OwnerName + "'s " + vehicle.Make + " " + vehicle.Model;
                }
                await _context.AddAsync(vehicle);

                await _context.SaveChangesAsync();
            }
            catch (Exception ex)
            {
                throw;
                // In here we would log the exception and return an error message to the user
            }
        }