public ActionResult MakeContract(MakeContractModel contract)
        {
            Clients client;

            //если клиент с таким именем уже существует, то берем его
            //если нет то создаем новый
            try
            {
                client = new ClientRepository()
                   .GetAll()
                   .Where(x => x.name.TrimEnd() == contract.clientName).First();
            }
            catch
            {
                //создаем клиента
                client = new Clients
                {
                    name = contract.clientName
                };
            }

            Projects project = new Projects
            {
                description = contract.projectDescription,
                name = contract.projectName,
                deadline = DateTime.Now.AddDays(20.0)
            };

            Agents agent = new AgentRepository().GetAll().Where(x => x.name.TrimEnd() == contract.agentName).First();

            Builders builder = new BuilderRepository().GetAll().Where(x => x.name.TrimEnd() == contract.builderName).First();

            Contracts contractToAdd = new Contracts()
            {
                agentId = agent.id,
                builderId = builder.id,
                clientId = client.id,
                Clients = client,
                projectId = project.id,
                Projects = project
            };

            new ContractRepository().Save(contractToAdd);

            return RedirectToAction("Index");
        }
		private void detach_Contracts(Contracts entity)
		{
			this.SendPropertyChanging();
			entity.Projects = null;
		}
		private void attach_Contracts(Contracts entity)
		{
			this.SendPropertyChanging();
			entity.Projects = this;
		}
 partial void DeleteContracts(Contracts instance);
 partial void UpdateContracts(Contracts instance);
 partial void InsertContracts(Contracts instance);