Пример #1
0
        public void Create(string name, int idSponsor, int idTypePlan, string idsInterested, string description = null,
                           double cost = 0)
        {
            Plan plan = new Plan();

            plan.Name       = name;
            plan.Type       = new TypePlan();
            plan.Type.Id    = idTypePlan;
            plan.Sponsor    = new User();
            plan.Sponsor.Id = idSponsor;
            if (description != null)
            {
                plan.Description = description;
            }
            if (cost != 0)
            {
                plan.Cost = cost;
            }

            var result = dao.insert(plan, idsInterested);

            if (result)
            {
                Console.WriteLine("Plano inserido com sucesso");
            }
            else
            {
                throw new Exception("Plano não pode ser inserido");
            }
        }