Ejemplo n.º 1
0
        public async Task <IActionResult> Create(Project project)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            project.PersonId = UserId();
            _context.Add(project);

            await _context.SaveChangesAsync();

            return(Ok());
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> Create([Bind(Include = "Id,ProjectId,UserId,Amount,DateInserted,PaymentStatus")] BackerProject backerProject)
        {
            if (ModelState.IsValid)
            {
                db.BackerProjects.Add(backerProject);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.ProjectId = new SelectList(db.Projects, "Id", "Title", backerProject.ProjectId);
            ViewBag.UserId    = new SelectList(db.Users, "Id", "PhotoUrl", backerProject.UserId);
            return(View(backerProject));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> VivaPayment(int amount, int projectId, int BackerId)
        {
            var transactionModel = new TransactionViewModel()
            {
                projectId   = projectId,
                transaction = await new PaymentManager().SendPaymentAsync()
            };

            if (transactionModel.transaction)
            {
                var backerProject = new BackerProject()
                {
                    Amount        = amount,
                    ProjectId     = projectId,
                    UserId        = BackerId,
                    DateInserted  = DateTime.Now,
                    PaymentStatus = "success"
                };

                db.BackerProjects.Add(backerProject);

                var project = await db.Projects.FindAsync(projectId);

                project.CurrentFundAmount += amount;
                db.Entry(project).State    = EntityState.Modified;

                await db.SaveChangesAsync();
            }
            return(View(transactionModel));
        }
Ejemplo n.º 4
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            Project project = await db.Projects.FindAsync(id);

            db.Projects.Remove(project);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public async Task <ActionResult> Create(ProjectUpdateViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var update = new ProjectUpdate()
                {
                    ProjectId    = viewModel.ProjectId,
                    Text         = viewModel.Text,
                    DateInserted = DateTime.Now
                };
                db.ProjectUpdates.Add(update);
                await db.SaveChangesAsync();

                return(RedirectToAction("Details", "Project", new { id = viewModel.ProjectId }));
            }

            return(View(viewModel));
        }
Ejemplo n.º 6
0
        public async Task <ActionResult> Create(ProjectCommentViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var user   = _userManager.FindById(User.Identity.GetUserId());
                var myUser = db.Users.Where(x => x.AspNetUsersId.Equals(user.Id)).FirstOrDefault();

                var comment = new UserProjectComment()
                {
                    ProjectId    = viewModel.ProjectId,
                    Text         = viewModel.Text,
                    BackerId     = myUser.Id,
                    DateInserted = DateTime.Now
                };
                db.UserProjectComments.Add(comment);
                await db.SaveChangesAsync();

                return(RedirectToAction("Details", "Project", new { id = viewModel.ProjectId }));
            }

            return(View(viewModel));
        }
Ejemplo n.º 7
0
        public async Task CreateDboUser(string id)
        {
            var user = db.Users.Where(x => x.AspNetUsersId == id).FirstOrDefault();

            if (user == null)
            {
                user = new Models.Database.User()
                {
                    AspNetUsersId = id
                };
                db.Users.Add(user);

                await db.SaveChangesAsync();
            }
        }
Ejemplo n.º 8
0
        public async Task <ActionResult> Create(RewardViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var reward = new Reward()
                {
                    ProjectId         = viewModel.ProjectId,
                    Name              = viewModel.Title,
                    Description       = viewModel.Description,
                    MaxAvailable      = viewModel.MaxAvailable,
                    CurrentAvailable  = viewModel.MaxAvailable,
                    MinRequiredAmount = viewModel.MinAmount,
                    MaxRequiredAmount = viewModel.MaxAmount,
                    DateInserted      = DateTime.Now,
                    IsAvailable       = true,
                };
                db.Rewards.Add(reward);
                await db.SaveChangesAsync();

                return(RedirectToAction("Edit", "Project", new { id = viewModel.ProjectId }));
            }

            return(View(viewModel));
        }
Ejemplo n.º 9
0
        public async Task <ActionResult> Edit(UserDetailsViewModel userViewModel)
        {
            if (ModelState.IsValid)
            {
                var user = await db.Users.FindAsync(userViewModel.Id);

                if (user == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                var aspnetUser = user.AspNetUser;
                aspnetUser.Email           = userViewModel.Email;
                aspnetUser.FirstName       = userViewModel.FirstName;
                aspnetUser.LastName        = userViewModel.LastName;
                aspnetUser.PhoneNumber     = userViewModel.PhoneNumber;
                db.Entry(aspnetUser).State = EntityState.Modified;

                await db.SaveChangesAsync();

                return(RedirectToAction("Details", "Users", new { id = userViewModel.Id }));
            }
            return(View(userViewModel));
        }