Beispiel #1
0
    protected void DeletePlotButton_Click(object sender, EventArgs e)
    {
        try
        {
            // Get the common web service instance.

            ServiceAccess           serviceLoader = ServiceAccess.GetInstance();
            FarmService.FarmService farmService   = serviceLoader.GetFarm();

            int plotId = 0;
            int.TryParse(PlotIdHiddenField.Value, out plotId);

            farmService.DeletePlotContact(plotId, LoginUserId);
            int farmId = 0;
            int.TryParse(FarmIdHiddenField.Value.ToString(), out farmId);
            int plotCount = farmService.GetPlotCountForFarm(farmId);
            if (plotCount == 0)
            {
                Response.Redirect("~/Members/FarmManagement.aspx");
            }
            else
            {
                Response.Redirect("~/Members/ViewFarm.aspx?farmId=" + FarmIdHiddenField.Value.ToString());
            }
        }
        catch (Exception exception)
        {
            log.Error("UNKNOWN ERROR WHILE DELETING PLOT:", exception);
            if (exception.Message.Contains("This action will cause Farm to be deleted and the Parent-Farm is Active. Hence Plot Cannot be deleted"))
            {
                MessageLiteral.Text = "Error: Farm is currently Firmed Up. It is not possible to delete any Firmed Up mailing plan or Farm. If you still want to delete it, please speak to Customer Service 1-800-Mailing";
            }

            else
            {
                MessageLiteral.Text = "Error: Unable to delete Plot";
            }
        }
    }