Пример #1
0
    public void ReplaceInvestmentRounds(InvestmentRound newInvestmentRound)
    {
        var index     = GameComponentsLookup.InvestmentRounds;
        var component = (InvestmentRoundsComponent)CreateComponent(index, typeof(InvestmentRoundsComponent));

        component.InvestmentRound = newInvestmentRound;
        ReplaceComponent(index, component);
    }
Пример #2
0
        public async Task <IActionResult> Create([Bind("ID,DateCreated,Title,InventionID,ExpertServiceID, IsOpenForFunding")] InvestmentRound investmentRound)
        {
            if (ModelState.IsValid)
            {
                _context.Add(investmentRound);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            PopulateInventionDropDownList(investmentRound.Invention);
            PopulateExpertServiceDropDownList(investmentRound.ExpertService);
            return(View(investmentRound));
        }
Пример #3
0
        public async Task <IActionResult> CreateDIY([Bind("Invention.Title,Invention.LongDescription,Invention.Valuation,ExpertService.Title,ExpertService.Cost,ExpertService.MaxDaysToComplete")] InventionViewModel inventionCollection)
        {
            //two ways to chain: 1) add a couple or triple of models to a view controller, or 2) just chain them together with adds. Think #2 is better.

            if (ModelState.IsValid)
            {
                var       user      = User.FindFirst(ClaimTypes.NameIdentifier).Value;
                Invention invention = new Invention();
                invention.Title               = Request.Form["Invention.Title"];
                invention.LongDescription     = Request.Form["Invention.LongDescription"];
                invention.Valuation           = Convert.ToInt16(Request.Form["Invention.Valuation"]);
                invention.IsForSale           = false;
                invention.IsOpenForFunding    = true;
                invention.IsPublished         = true;
                invention.ApplicationUserId   = user;
                inventionCollection.Invention = invention;
                inventionCollection.Invention.ApplicationUserId = user;
                ExpertService expertService = new ExpertService();
                expertService.Title             = Request.Form["ExpertService.Title"];
                expertService.IsPublished       = false;
                expertService.LongDescription   = "I will use the funding to work on my invention and to pay for expenses.";
                expertService.MaxDaysToComplete = Convert.ToInt16(Request.Form["ExpertService.MaxDaysToComplete"]);
                expertService.Cost                = Convert.ToInt16(Request.Form["ExpertService.Cost"]);
                expertService.ServiceTypeID       = 2;
                expertService.ApplicationUserId   = user;
                inventionCollection.ExpertService = expertService;
                _context.Add(invention);
                _context.Add(expertService);
                _context.SaveChanges();
                InvestmentRound investmentRound = new InvestmentRound();
                investmentRound.InventionID      = invention.ID;
                investmentRound.RaiseAmount      = expertService.Cost;
                investmentRound.Title            = "DIY Round";
                investmentRound.IsOpenForFunding = true;
                investmentRound.ExpertServiceID  = expertService.ID;
                investmentRound.RoundStatusID    = 1;
                _context.Add(investmentRound);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { ID = inventionCollection.Invention.ID }));
            }
            return(View(inventionCollection));
        }
Пример #4
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,DateCreated,Title,RaiseAmount,IsOpenForFunding")] InvestmentRound investmentRound)
        {
            if (id != investmentRound.ID)
            {
                return(NotFound());
            }
            var investmentRoundOriginal = _context.InvestmentRound.Single(m => m.ID == id);

            if (ModelState.IsValid)
            {
                try
                {
                    //we just want to update updateable fields
                    investmentRoundOriginal.Title            = investmentRound.Title;
                    investmentRoundOriginal.RaiseAmount      = investmentRound.RaiseAmount;
                    investmentRoundOriginal.IsOpenForFunding = investmentRound.IsOpenForFunding;



                    _context.Update(investmentRoundOriginal);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!InvestmentRoundExists(investmentRound.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction("Details", "Inventions", new { ID = investmentRoundOriginal.InventionID }));
            }
            PopulateInventionDropDownList(investmentRound.Invention);
            return(View(investmentRound));
        }
Пример #5
0
        public async Task <IActionResult> Invest(int?id)
        {
            //if user is not logged in, direct them to login or create account (with a redirect back to here) - should be automatic



            //if the user does not have an invention, direct them to create one (with a redirect back to here)
            //first we need to associate inventions with the active user.
            //to start, lets just create an invention

            if (id == null)
            {
                return(NotFound());
            }

            var expertService = await _context.ExpertService.Include(m => m.ServiceType).SingleOrDefaultAsync(m => m.ID == id);

            if (expertService == null)
            {
                return(NotFound());
            }

            var user = User.FindFirst(ClaimTypes.NameIdentifier).Value;

            Invention invention = new Invention();

            invention.ApplicationUserId = user;
            invention.Title             = User.Identity.Name + "'s Invention";
            invention.IsOpenForFunding  = true;
            //this will result in 20% of the invention being allocated to the round
            invention.Valuation   = expertService.Cost * 4;
            invention.IsPublished = true;

            _context.Add(invention);
            _context.SaveChanges();

            //await _context.SaveChangesAsync();


            //if the user has multiple inventions, ask them to select which one, assume the last updated and give them an option to change

            //now add an investment round, with the expert service and the invention specified - create investment round and associate with invention and expert service

            InvestmentRound investmentRound = new InvestmentRound();

            investmentRound.ExpertServiceID  = expertService.ID;
            investmentRound.InventionID      = invention.ID;
            investmentRound.RaiseAmount      = expertService.Cost;
            investmentRound.Title            = string.Format("Round for {0}", expertService.Title);
            investmentRound.IsOpenForFunding = true;
            investmentRound.RoundStatusID    = 1;


            _context.Add(investmentRound);
            await _context.SaveChangesAsync();

            //TempData["message"] = "Update Invention Title and add Long Description to.  that tells people just enough to get them to invest but without disclosing patentable subject matter, then click on Save and Publish to get it listed under the Invest tab!";
            TempData["isNew"] = "true";
            return(RedirectToAction("Edit", "Inventions", new { ID = invention.ID }));

            //We will have the amount to raise, we need to ask what the Current Value of the invention is and minimum investment - now this action should be done, and we should transition to investment round

            //Then we can calculate the equity that all investors are getting and the amount of equity for the minimum investment

            //Then this one should be marked open for funding
        }