using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using ScaffoldingExample.Models;

namespace QuickForm
{
    public class QuickFormProjectDelete
    {
        public static void CheckIsDeletionPermitted(HttpSessionStateBase Session, QuickFormModel quickFormModel, out bool IsDeletionPermitted, out string ErrorMessage)
        {
            IsDeletionPermitted = true;
            ErrorMessage = "";

            string controller = quickFormModel.ControllerName;

            if (controller == "Processor")
            {
                Processor data = (Processor)quickFormModel.CurrentModel;
                int count = data.Computers.Count;
                if (count > 0)
                {
                    IsDeletionPermitted = false;
                    ErrorMessage = "Невозможно удалить значение ''" + data.ProcessorName + "'', так как в систему введены связанные с ним компьютеры.";
                }
            }
        }
    }
}