Ejemplo n.º 1
0
        public IActionResult AddProject(AddProjectModel model)
        {
            var blockchain = dbContext.Blockchains.Where(b => b.Id == model.SelectedBlockchainId).SingleOrDefault();

            if (blockchain == null)
            {
                return(BadRequest("Blockchain not found with id: " + model.SelectedBlockchainId + "."));
            }

            var apiKey    = Guid.NewGuid();
            var apiSecret = RandomKeyGenerator.GetUniqueKey(128);

            var project = new Project
            {
                Name       = model.Name,
                UserId     = CurrentUser.Id,
                ApiKey     = apiKey,
                ApiSecret  = apiSecret,
                Blockchain = blockchain,
                CreatedUtc = DateTime.UtcNow
            };

            dbContext.Projects.Add(project);
            dbContext.SaveChanges();

            return(RedirectToAction(nameof(Project), new { projectId = project.Id }));
        }
Ejemplo n.º 2
0
        public IActionResult AddProject()
        {
            var model       = new AddProjectModel();
            var blockchains = dbContext.Blockchains.ToList();

            model.Blockchains = blockchains;

            return(View(model));
        }