public List <Backer> FindBackerByName(BackerOption BackerOpt)
 {
     return(db.Backers
            .Where(b => b.FirstName == BackerOpt.FirstName)
            .Where(b => b.LastName == BackerOpt.LastName)
            .ToList());
 }
        public Backer UpdateBacker(BackerOption backerOption, int backerId)
        {
            Backer backer = db.Backers.Find(backerId);

            if (backerOption.FirstName != null)
            {
                backer.FirstName = backerOption.FirstName;
            }
            if (backerOption.LastName != null)
            {
                backer.LastName = backerOption.LastName;
            }
            if (backerOption.Profession != null)
            {
                backer.Profession = backerOption.Profession;
            }
            if (backerOption.Address != null)
            {
                backer.Address = backerOption.Address;
            }
            if (backerOption.Email != null)
            {
                backer.Email = backerOption.Email;
            }
            if (backerOption.Password != null)
            {
                backer.Password = backerOption.Password;
            }
            db.SaveChanges();
            return(backer);
        }
        //Backer Views

        //Backer Profile
        public IActionResult BackerProfile([FromQuery] int backerId)
        {
            BackerOption      backerOption      = backerService.FindBacker(backerId);
            BackerOptionModel backerOptionModel = new BackerOptionModel()
            {
                Backer = backerOption
            };

            return(View(backerOptionModel));
        }
        public IActionResult UpdateBacker([FromRoute] int id)
        {
            BackerOption      backerOption      = backerService.FindBacker(id);
            BackerOptionModel backerOptionModel = new BackerOptionModel()
            {
                Backer = backerOption
            };

            return(View(backerOptionModel));
        }
        public BackerOption UpdateBacker(int id, BackerOption backerOption)
        {
            Backer backer = dbContext.Backers.Find(id);

            BackerOptToBacker(backerOption, backer);
            dbContext.SaveChanges();

            return(new BackerOption
            {
                FirstName = backer.FirstName,
                LastName = backer.LastName,
                Email = backer.Email
            });
        }
        public Backer CreateBacker(BackerOption backerOption)   //ok
        {
            Backer backer = new Backer
            {
                FullName = backerOption.FullName,
                Address  = backerOption.Address,
                Email    = backerOption.Email,
                Phone    = backerOption.Phone
            };

            db.Backers.Add(backer);
            db.SaveChanges();
            return(backer);
        }
        public Backer FindBackerByEmail(BackerOption backOption)
        {
            if (backOption == null)
            {
                return(null);
            }
            if (backOption.Email == null)
            {
                return(null);
            }

            return(db.Backers
                   .Where(back => back.Email == backOption.Email)
                   .FirstOrDefault());
        }
Exemple #8
0
        public Backer CreateBacker(BackerOption backOption)
        {
            Backer backer = new Backer
            {
                FirstName = backOption.FirstName,
                LastName  = backOption.LastName,
                Email     = backOption.Email,
                Username  = backOption.Username,
                Password  = backOption.Password,
                Dob       = backOption.Dob
            };

            db.Backers.Add(backer);
            db.SaveChanges();

            return(backer);
        }
        public BackerOption CreateBacker(BackerOption backerOption)
        {
            Backer backer = new Backer
            {
                FirstName = backerOption.FirstName,
                LastName  = backerOption.LastName,
                Email     = backerOption.Email
            };

            dbContext.Backers.Add(backer);
            dbContext.SaveChanges();
            return(new BackerOption
            {
                FirstName = backerOption.FirstName,
                LastName = backerOption.LastName,
                Email = backer.Email
            });
        }
        //CRUD

        /// Creating a new Backer (User) for the platform
        public Backer CreateBacker(BackerOption backerOption)
        {
            Backer backer = new Backer
            {
                FirstName  = backerOption.FirstName,
                LastName   = backerOption.LastName,
                Email      = backerOption.Email,
                Address    = backerOption.Address,
                Profession = backerOption.Profession,
                Password   = backerOption.Password,
                Active     = true // Active by default
            };

            db.Backers.Add(backer);
            db.SaveChanges();

            return(backer);
        }
Exemple #11
0
        public BackerOption AddBacker([FromForm] BackerOption backerOption)
        {
            if (backerOption == null)
            {
                return(null);
            }
            BackerOption backerOpt = new BackerOption
            {
                FirstName = backerOption.FirstName,
                LastName  = backerOption.LastName,
                Email     = backerOption.Email,
                Id        = backerOption.Id
            };


            BackerOption backerOptions = backerService.CreateBacker(backerOpt);

            return(backerOptions);
        }
        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}  ");
            }
        }
Exemple #13
0
 public BackerOption UpdateBacker(int id, BackerOption backerOpt)
 {
     return(backerService.UpdateBacker(id, backerOpt));
 }
 public Backer LoginBacker([FromBody] BackerOption backerOption)
 {
     return(backerManager.FindBackerByEmail(backerOption));
 }
 public Backer EditBacker([FromBody] BackerOption backerOption, int id)
 {
     return(backerManager.UpdateBacker(backerOption, id));
 }
 public Backer CreateBacker([FromBody] BackerOption backerOption)
 {
     return(backerManager.CreateBacker(backerOption));
 }
 private static void BackerOptToBacker(BackerOption backerOpt, Backer backer)
 {
     backer.FirstName = backerOpt.FirstName;
     backer.LastName  = backerOpt.LastName;
     backer.Email     = backerOpt.Email;
 }