Exemple #1
0
        public FundingPackage AddFundingPackage(FundingPackageOption fundingPackageOption)   //ok
        {
            Project project = db.Projects.Find(fundingPackageOption.ProjectId);
            FundingPackageManagment fundingPackageManager = new FundingPackageManagment(db);
            FundingPackage          fundingPackage        = fundingPackageManager.CreateFundingPackage(fundingPackageOption);

            project.FundingPackages.Add(fundingPackage);

            db.SaveChanges();
            return(fundingPackage);
        }
        public FundingPackage CreateFundingPackage(FundingPackageOption fundingPackageOption)   //ok
        {
            IProjectManager projMng = new ProjectManagment(db);
            Project         project = new Project();

            project = db.Projects.Find(fundingPackageOption.ProjectId);
            FundingPackage fundingPackage = new FundingPackage
            {
                Price   = fundingPackageOption.Price ?? 0,
                Reward  = fundingPackageOption.Reward,
                Project = project
            };

            db.FundingPackages.Add(fundingPackage);
            db.SaveChanges();

            return(fundingPackage);
        }
 public int AddFundingPackage([FromBody] FundingPackageOption fundingPackageOption)
 {
     return(projectCreatorManager.AddFundingPackage(fundingPackageOption).Id);
 }
        static void Main(string[] args)
        {
            using CrmDbContext db = new CrmDbContext();

            IProjectManager        projectMng  = new ProjectManagment(db);
            IProjectCreatorManager projCrMng   = new ProjectCreatorManagment(db);
            IBackerManager         backerMangr = new BackerManagment(db);
            IFundingPackageManager fundMangr   = new FundingPackageManagment(db);


            ProjectCreatorOption projectCreatorOption = new ProjectCreatorOption
            {
                FullName = "Stelios",
                Address  = "SKG",
                Email    = "email"
            };
            ProjectCreator projectCreator = projCrMng.CreateProjectCreator(projectCreatorOption);

            BackerOption backerOpt = new BackerOption()
            {
                FullName = "mixalis",
                Address  = "ptolem",
                Email    = "*****@*****.**",
                Phone    = "12345"
            };

            ProjectOption projectOption = new ProjectOption
            {
                ProjectCreatorId = 1,
                Title            = "B",
                Description      = "description B",
                StatusUpdate     = "status B",
                TotalFundings    = 0m,
                Goal             = 1000m,
                Category         = "Fashion",
                Active           = true
            };



            FundingPackageOption fundOpt = new FundingPackageOption
            {
                Price     = 158,
                Reward    = "nadd",
                ProjectId = 2
            };

            //Backer backer = backerMangr.CreateBacker(backerOpt);
            //Project project = projectMng.CreateProject(projectOption);
            FundingPackage funding = projCrMng.AddFundingPackage(fundOpt);

            //Console.WriteLine(
            //          $"Id= {backer.Id} Address= {backer.Address} Email= {backer.Email}  ");

            //Console.WriteLine(
            //          $"Id= {project.Id} Description= {project.Description} StatusUpdate= {project.StatusUpdate}  ");

            //Console.WriteLine(
            //          $"Id= {funding.Id} Reward= {funding.Reward} ");

            // BackerFundingPackage bfp = backerMangr.Fund(funding, 1);
            //BackerFundingPackage bfp2 = backerMangr.Fund(2, 2, 1);
            //BackerFundingPackage bfp3 = backerMangr.Fund(3, 2, 1);

            //Console.WriteLine(
            //          $"Id= {bfp.Id} Backer= {bfp.Backer.Id} FundingPackage= {bfp.FundingPackage.Id}  ");

            List <BackerFundingPackage> bfps = backerMangr.ShowFundingPackageByBacker(1);

            foreach (var bfp in bfps)
            {
                Console.WriteLine(
                    $"Title= {bfp.Backer} TotalFundings= {bfp.Project} Goal= {bfp.Id}  ");
            }
        }