Exemplo n.º 1
0
        /// <summary>
        /// Method to Delete from the database the Route passed in the parameters
        /// </summary>
        /// <param name="route">Object Route to Delete</param>
        public async Task <ApiResponse> Delete(int idRoute)
        {
            try
            {
                if (!await _gameRepository.ContainsRoute(idRoute))
                {
                    await _routeBusiness.DeleteAllFromRoute(idRoute);

                    await _teamBusiness.DeleteTeamRoutesFromRoute(idRoute);
                }
                _context.Routes.Remove(await _context.Routes.FindAsync(idRoute));
                _context.SaveChanges();
                return(new ApiResponse {
                    Status = ApiStatus.Ok, Message = ApiAction.Delete
                });
            }
            catch (Exception e)
            {
                return(TranslateError.Convert(e));
            }
        }