Exemple #1
0
        public ActionResult Create(RecipeModel recipeModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(recipeModel));
            }

            var recipe = Mapper.Map <RecipeModel, Recipe>(recipeModel);

            recipe.User = _context.Users.First(u => u.UserName == this.UserName);

            _context.Recipes.Add(recipe);

            foreach (var s in recipeModel.IntegrationSettings)
            {
                var integration       = _context.Integrations.FirstOrDefault(i => i.Id == s.Key);
                var integrationRecipe = new IntegrationRecipe()
                {
                    Configurations = new Dictionary <string, string> {
                        { "Folder", s.Value }
                    },
                    Integration = integration,
                    Recipe      = recipe
                };

                _context.IntegrationRecipes.Add(integrationRecipe);
            }


            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemple #2
0
        public ActionResult Index(FtpModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            var configurations = new Dictionary <string, string>
            {
                { "User", model.User },
                { "Password", model.Password },
                { "Host", model.Host },
                { "Port", model.Port ?? "" }
            };

            var integration = new Integration
            {
                IntegrationSystem = IntegrationSystem.Ftp,
                Name     = model.Name,
                User     = _context.Users.GetByUserName(UserName),
                Settings = configurations
            };

            _context.Integrations.Add(integration);

            _context.SaveChanges();

            return(RedirectToAction("Index", "Integration"));
        }
        public ActionResult Confirm()
        {
            _dropBoxClient = (DropBoxClient)Session["dropboxObject"] ?? new DropBoxClient();

            _dropBoxClient.GetAccessToken();

            var apiSecret   = _dropBoxClient.ApiSecret;
            var accessToken = _dropBoxClient.AccessToken;

            var user = _context.Users.GetByUserName(UserName);

            var information = _dropBoxClient.GetInformation();

            var integration = new Integration()
            {
                Name = "Conta - " + information.Name + "(" + information.Email + ")",
                IntegrationSystem = IntegrationSystem.DropBox,
                User     = user,
                Settings = new Dictionary <string, string>()
                {
                    { "apiSecret", apiSecret }, { "accessToken", accessToken }
                }
            };

            _context.Integrations.Add(integration);
            _context.SaveChanges();

            return(RedirectToAction("Index", "Integration"));
        }
        public ActionResult ConfirmDelete(int id)
        {
            var integration = _context.Integrations.FirstOrDefault(i => i.Id == id);

            _context.Integrations.Remove(integration);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
        public ActionResult SignUp(SignUpModel suModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(suModel));
            }

            Mapper.CreateMap <SignUpModel, User>().ForMember(m => m.UserName, a => a.MapFrom(mf => mf.User));
            var user = Mapper.Map <User>(suModel);

            _context.Users.Add(user);
            _context.SaveChanges();

            ViewBag.Message = new { Type = "Success", Message = "Cadastrado com sucesso!" };

            return(RedirectToAction("Index"));
        }