Пример #1
0
        public ActionResult Register(RegisterViewModel registerViewModel)
        {
            if (ModelState.IsValid)
            {
                IUserBLL userBLL = new UserBLL();
                if (userBLL.Register(registerViewModel.Email, registerViewModel.Password))
                {
                    Guid userId;
                    userBLL.Login(registerViewModel.Email, registerViewModel.Password, out userId);

                    // create default category and article in the account

                    IArticleBLL articleBLL = new ArticleBLL();
                    articleBLL.CreateCategory("default", userId);

                    List <Guid> categoryIds = new List <Guid>();
                    foreach (CategoryDTO categoryDTO in articleBLL.GetAllCategories(userId))
                    {
                        categoryIds.Add(categoryDTO.Id);
                    }
                    articleBLL.CreateArticle("default title", "default content", categoryIds.ToArray(), userId);


                    return(RedirectToAction(nameof(Login)));
                }
                return(View(registerViewModel));
            }
            return(View(registerViewModel));
        }
Пример #2
0
        public ActionResult Create(Article article)
        {
            SystemFail error = new SystemFail();

            if (ModelState.IsValid)
            {
                ArticleBLL.CreateArticle(article, error);
                if (!error.Error)
                {
                    TempData["StartUpScript"] = "$.notify('Se creo correctamente el articulo','success');";
                }
                else
                {
                    TempData["StartUpScript"] = "$.notify('Ocurrio un error al crear el articulo  Error" + error.Message + "','error');";
                }
            }
            else
            {
                ViewBag.StartupScript = "$.notify('Se han encontrador errores en la información ingresada. Por favor revisela','warn')";
                return(View(article));
            }

            return(RedirectToAction("Index"));
        }