Example #1
0
        public ActionResult New(ProjectForm projectForm)
        {
            if (ModelState.IsValid)
            {
                Project newProject = new Project();
                newProject.ProjectName = projectForm.ProjectName;
                newProject.ProjectDescription = projectForm.ProjectDescription;
                newProject.CurrentFund = 0;
                newProject.Goal = projectForm.Goal;
                newProject.StartDate = DateTime.Now;
                newProject.EndDate = newProject.StartDate + TimeSpan.FromDays(projectForm.FundingLength);
                int CatID = int.Parse(projectForm.SelectedCategory);
                newProject.Category = CategoryRepository.Find(CatID);
                newProject.Creator = (User)Session["CurrentUser"];
                newProject.ImageUrl = projectForm.ImageUrl;

                newProject = ProjectRepository.Save(newProject);

                projectForm.ProjectID = newProject.ProjectID;

                return View("NewBis", projectForm);
            }
            else
            {
                List<SelectListItem> TempList = new List<SelectListItem>();
                foreach (Category c in CategoryRepository.FindAll())
                {
                    TempList.Add(
                        new SelectListItem
                        {
                            Value = c.CategoryID.ToString(),
                            Text = c.CategoryName,
                            Selected = false,
                            Disabled = false,
                            Group = null
                        }
                    );
                }

                projectForm.Categories = TempList;

                return View(projectForm);
            }
        }
Example #2
0
        public ActionResult New()
        {
            ProjectForm PF = new ProjectForm();

            List<SelectListItem> TempList = new List<SelectListItem>();
            foreach (Category c in CategoryRepository.FindAll())
            {
                TempList.Add(
                    new SelectListItem
                    {
                        Value = c.CategoryID.ToString(),
                        Text = c.CategoryName,
                        Selected = false,
                        Disabled = false,
                        Group = null
                    }
                );
            }

            PF.Categories = TempList;

            return View(PF);
        }
Example #3
0
        public ActionResult NewBis(ProjectForm projectForm)
        {
            foreach (Reward r in projectForm.Rewards)
            {
                if (r.RewardTitle != null && r.RewardTitle.Trim() != string.Empty)
                {
                    r.ProjectID = projectForm.ProjectID;
                    RewardRepository.Save(r);
                }
            }

            return RedirectToAction("Details", new { id = projectForm.ProjectID });
        }