Esempio n. 1
0
    protected void ButtonDelete_Click(object sender, EventArgs e)
    {
        string routeName = RouteName.Value;

        try
        {
            if (string.IsNullOrEmpty(routeName))
            {
                return;
            }
            //non posso eliminare una traccia che appartiene ad un alro utente
            //(se mai riesco a editarla)
            if (route != null && route.OwnerId != LoginState.User.Id)
            {
                return;
            }

            string path = PathFunctions.GetRoutePathFromName(routeName);
            TryDeleting(path);
            path = PathFunctions.GetWorkingPath(path);
            TryDeleting(path);
            if (route != null)
            {
                DBHelper.DeleteRoute(route);
            }
            GpxParser.RemoveFromSession(routeName);
            UploadedImages.RemoveFromSession(routeName);
            //forza il ricaricamento della pagina
            Response.Redirect(Request.Url.ToString(), true);
        }
        catch (Exception ex)
        {
            Log.Add("Error deleting route '{0}': '{1}'", routeName, ex.ToString());
            ScriptManager.RegisterStartupScript(this, GetType(), "ErrorDeleting", string.Format("alert('Errore durante l'eliminazione: {0}.');", ex.Message), true);
        }
    }