Exemple #1
0
 public ActionResult AddPost(PostModel post)
 {
     try
     {
         InsertMethods.AddNewPost(post, User.Identity.Name);
     }
     catch (Exception e)
     {
         // ignored
     }
     return(RedirectToAction("Index", "MainPage"));
 }
Exemple #2
0
 public ActionResult Register(RegisterModel model)
 {
     if (ModelState.IsValid)
     {
         var status = InsertMethods.RegisterNewUser(model);
         if (status == (int)Registration.Success && CheckMethods.IsUserExists(model.Login))
         {
             FormsAuthentication.SetAuthCookie(model.Login, true);
             return(RedirectToAction("Index", "Account"));
         }
     }
     ViewBag.Error = "Already exists";
     return(View("~/Views/Register/Registration.cshtml", model));
 }
Exemple #3
0
        public ActionResult UserUpdatePost(int postId, string title, string content)
        {
            using (BlogDbContext db = new BlogDbContext())
            {
                var username = User.Identity.Name;
                if (CheckMethods.IsUsersPost(postId, username))
                {
                    InsertMethods.UpdatePost(postId, title, content);
                    return(RedirectToAction("ShowPost", "MainPage", new { postId }));
                }
            }

            return(RedirectToAction("AccessDenied", "Error"));
        }
Exemple #4
0
        public JsonResult PostRegisterUser(string username, string name, string surname, string password, string email)
        {
            InsertMethods.RegisterNewUser(username, name, surname, password, email);
            if (CheckMethods.IsUserExists(username))
            {
                JsonResult res = new JsonResult()
                {
                    Data = new { status = "succesful" }
                };
                return(res);
            }

            var err = new Error()
            {
                ErrorCode = HttpStatusCode.InternalServerError, Message = "Server error"
            };

            JsonConvert.SerializeObject(err);
            return(new JsonResult()
            {
                Data = err
            });
        }
Exemple #5
0
        //
        /// <summary>
        /// Insert column |tableName| (ColName,ColType,IsAllowNull(true/false),DefaultValue;...)
        /// Insert values |tableName| (|params|)
        /// </summary>
        /// <param name="query"></param>
        private static void Insert(string query)
        {
            string param = query.Substring(6);

            InsertMethods.Execute(param);
        }