예제 #1
0
        // GET: SiteHome

        public ActionResult Home()
        {
            PostCommentModel model = new PostCommentModel();

            model.Posts = _uow.GetRepo <Post>().GetList();
            return(View(model));
        }
예제 #2
0
        public bool UniqEmailCheck(string mail)
        {
            var data = _uow.GetRepo <Users>().Where(x => x.Email == mail).FirstOrDefault();

            if (data == null)
            {
                return(true);
            }
            return(false);
        }
예제 #3
0
        public bool UniqCategoryCheck(string name)
        {
            var data = _uow.GetRepo <Category>().Where(x => x.Name == name).FirstOrDefault();

            if (data == null)
            {
                return(true);
            }
            return(false);
        }
예제 #4
0
        public ActionResult Register(Users model)
        {
            var valid = new UsersRegisterValidator(_uow).Validate(model);

            if (valid.IsValid)
            {
                model.RoleId = 2;
                _uow.GetRepo <Users>().Add(model);
                _uow.Commit();
                return(RedirectToAction("Home", "SiteHome"));
            }


            else
            {
                valid.Errors.ToList().ForEach(x => ModelState.AddModelError(x.PropertyName, x.ErrorMessage));
            }
            return(View());
        }
예제 #5
0
        public ActionResult Login(Users model)
        {
            var validator = new UsersValidator().Validate(model);

            if (validator.IsValid)
            {
                var result = _uow.GetRepo <Users>().Where(x => x.Email == model.Email && x.Password == model.Password).FirstOrDefault();
                if (result != null)
                {
                    FormsAuthentication.SetAuthCookie(result.Email, false);
                    return(Redirect("/Dashboard"));
                }
                else
                {
                    ViewBag.msg = "Böyle bir kullanıcı mevcut değildir.";
                    return(View());
                }
            }
            else
            {
                validator.Errors.ToList().ForEach(x => ModelState.AddModelError(x.PropertyName, x.ErrorMessage));
            }
            return(View());
        }
예제 #6
0
        // GET: Dashboard/Category
        public ActionResult Category(Category model)
        {
            var data = _uow.GetRepo <Category>().GetList();

            return(View(data));
        }
예제 #7
0
        public ActionResult Users(Users model)
        {
            var data = _uow.GetRepo <Users>().GetList();

            return(View(data));
        }
예제 #8
0
        public ActionResult Post()
        {
            var data = _uow.GetRepo <Post>().GetList();

            return(View(data));
        }