public ViewResult MakeAnOffer(int projId, int buyerId)
        {
            Project       proj                     = _projRepo.GetProjById(projId);
            CryptcurValue cryptcurValue            = _projRepo.GetValuationById(projId);
            bool          thisBuyerHasPendingOffer = _transRepo.ThisBuyerHasPendingOffer(buyerId, projId);
            List <int>    acceptCurrency           = new List <int>();

            if (cryptcurValue.AcceptBitcoid)
            {
                acceptCurrency.Add(Cryptocurrency.Bitcoin);
            }
            if (cryptcurValue.AcceptEthereum)
            {
                acceptCurrency.Add(Cryptocurrency.Ethereum);
            }
            if (cryptcurValue.AcceptLitecoin)
            {
                acceptCurrency.Add(Cryptocurrency.Litecoin);
            }
            List <Offer> historyOffers = _transRepo.GetMyOffersByProjIdBuyerId(projId, buyerId).ToList();

            MakeAnOfferViewModel makeAnOfferViewModel = new MakeAnOfferViewModel
            {
                ProjId                  = projId,
                BuyerId                 = buyerId,
                AcceptCurrency          = acceptCurrency,
                HistoryOffers           = historyOffers,
                ThisProjHasPendingOffer = thisBuyerHasPendingOffer
            };

            return(View(makeAnOfferViewModel));
        }
Exemplo n.º 2
0
        public ViewResult UpdateProject(int id)
        {
            var                    proj                   = _projRepo.GetProjById(id);
            CryptcurValue          cryptcurValue          = _projRepo.GetValuationById(id);
            CreateProjectViewModel createProjectViewModel = new CreateProjectViewModel
            {
                ProjId         = id,
                ProjName       = proj.ProjName,
                MissionState   = proj.MissionStatement,
                ProtdCompDate  = proj.ProtdCompDate,
                FullDescript   = proj.FullDescript,
                Progress       = proj.Progress,
                RepoLink       = proj.RepoLink,
                Value_bitcoin  = cryptcurValue.BitcoinValue,
                Value_ethereum = cryptcurValue.EthereumValue,
                Value_litecoin = cryptcurValue.LitecoinValue,
                Visibility     = proj.Visibility,
                ProjectStatus  = proj.ProjStatus,
            };

            return(View(createProjectViewModel));
        }
Exemplo n.º 3
0
        public IActionResult UpdateProject(CreateProjectViewModel createProjectViewModel)
        {
            var           proj          = _projRepo.GetProjById(createProjectViewModel.ProjId);
            CryptcurValue cryptcurValue = _projRepo.GetValuationById(proj.ProjectId);

            cryptcurValue.BitcoinValue   = createProjectViewModel.Value_bitcoin;
            cryptcurValue.EthereumValue  = createProjectViewModel.Value_ethereum;
            cryptcurValue.LitecoinValue  = createProjectViewModel.Value_litecoin;
            cryptcurValue.AcceptBitcoid  = createProjectViewModel.Value_bitcoin != 0;
            cryptcurValue.AcceptEthereum = createProjectViewModel.Value_ethereum != 0;
            cryptcurValue.AcceptLitecoin = createProjectViewModel.Value_litecoin != 0;

            if (ModelState.IsValid)
            {
                proj.ProtdCompDate = createProjectViewModel.ProtdCompDate;
                proj.FullDescript  = createProjectViewModel.FullDescript;
                proj.Progress      = createProjectViewModel.Progress;
                proj.RepoLink      = createProjectViewModel.RepoLink;
                proj.Visibility    = createProjectViewModel.Visibility;
                proj.ProjStatus    = createProjectViewModel.ProjectStatus;
                if (proj.ProjStatus == ProjStatus.Development_Completed)
                {
                    if (proj.CompleteDate == null)
                    {
                        proj.CompleteDate = DateTime.Today;
                    }
                }
                else
                {
                    proj.CompleteDate = null;
                }
                proj.Valuation = cryptcurValue;
                _projRepo.SaveChanges();
                return(RedirectToAction("Index", "Project", new { id = proj.ProjectId }));
            }

            return(View(createProjectViewModel));
        }