Beispiel #1
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            var resultEntry = new JsonResultEntry()
            {
                Success = false
            };

            try
            {
                if (Session != null)
                {
                    Session.UserState = null;
                    Session.SessionId = null;
                    Session.Session.Clear();
                }
                var abc = Sys_UserManager.Login(model.UserName, model.Password);
                if (ModelState.IsValid && Membership.ValidateUser(model.UserName, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                    if (CUtils.IsNullOrEmpty(returnUrl) || returnUrl == "/")
                    {
                        var url = Url.ActionLocalized("Index", "Home", new { area = "Auth" });
                        returnUrl = url;
                    }
                    resultEntry.Success          = true;
                    resultEntry.RedirectToOpener = true;
                    resultEntry.RedirectUrl      = returnUrl;
                }
                else
                {
                    var exitsData = "Tên đăng nhập hoặc mật khẩu không hợp lệ!";
                    resultEntry.AddMessage(exitsData);
                }


                return(Json(resultEntry));
                // If we got this far, something failed, redisplay form
                //ModelState.AddModelError("", "The user name or password provided is incorrect.");
                //return View(model);
            }
            catch (ValidationException valEx)
            {
                foreach (var ver in valEx.ValidationErrors)
                {
                    resultEntry.AddFieldError(ver.FieldName, ver.ErrorMessage);
                }
            }
            catch (Exception e)
            {
                resultEntry.SetFailed().AddException(this, e);
            }
            resultEntry.AddModelState(ViewData.ModelState);
            return(Json(resultEntry));
        }
Beispiel #2
0
        public virtual ActionResult Create(string folderName, string parentFolder, string parentUUID, FormCollection form)
        {
            JsonResultEntry resultEntry = new JsonResultEntry()
            {
                Success = true
            };

            try
            {
                if (ModelState.IsValid)
                {
                    TextFolder textFolder = new TextFolder(Repository, folderName).AsActual();
                    var        schema     = textFolder.GetSchema().AsActual();

                    SchemaPath schemaPath = new SchemaPath(schema);
                    IEnumerable <TextContent> addedCategories;
                    IEnumerable <TextContent> removedCategories;

                    ParseCategories(form, out addedCategories, out removedCategories);
                    ContentBase content;

                    content = ServiceFactory.TextContentManager.Add(Repository, textFolder, parentFolder, parentUUID, form, Request.Files, addedCategories, User.Identity.Name);

                    resultEntry.ReloadPage = true;

                    resultEntry.Success = true;
                }
            }
            catch (RuleViolationException ruleEx)
            {
                foreach (var item in ruleEx.Issues)
                {
                    resultEntry.AddFieldError(item.PropertyName, item.ErrorMessage);
                }
            }
            catch (Exception e)
            {
                resultEntry.SetFailed().AddException(e);
            }
            resultEntry.AddModelState(ViewData.ModelState);
            return(Json(resultEntry));
        }