예제 #1
0
        public ActionResult Create(EveryNoteUser everyNoteUser)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifierUser");

            if (ModelState.IsValid)
            {
                BusinessLayerResult <EveryNoteUser> res = everynoteuser_mngr.Insert(everyNoteUser);

                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message)); //ValidationSummary de error ların çıkmasını sağladık.
                    return(View(everyNoteUser));
                }

                string foldername = "user_" + res.Result.Id.ToString();
                string folderpath = Server.MapPath(string.Format("~/images/userimg/{0}", foldername));
                if (!Directory.Exists(folderpath))
                {
                    Directory.CreateDirectory(folderpath);
                }

                return(RedirectToAction("Index"));
            }

            return(View(everyNoteUser));
        }
예제 #2
0
        public ActionResult Create(User user)
        {
            ModelState.Remove("CreatedUserName");
            ModelState.Remove("CreatedOn");
            if (ModelState.IsValid)
            {
                BusinessLayerResult <User> businessLayerResult = userManager.Insert(user);
                if (businessLayerResult.Errors.Count > 0)
                {
                    businessLayerResult.Errors.ForEach(q => ModelState.AddModelError("", q.Message));
                    return(View(user));                    // Aynı sayfaya hata bilgileri ile modelin geri yollanması
                }

                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
예제 #3
0
        public ActionResult Create(EverynoteUser everynoteUser)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUserame");

            if (ModelState.IsValid)
            {
                BusinessLayerResult <EverynoteUser> res = everynoneUserManager.Insert(everynoteUser);

                if (res.Errors.Count > 0)
                {
                    res.Errors.ForEach(x => ModelState.AddModelError("", x.Message));
                    return(View(everynoteUser));
                }

                return(RedirectToAction("Index"));
            }

            return(View(everynoteUser));
        }