コード例 #1
0
ファイル: UsersController.cs プロジェクト: KamranG12/admins
        public ActionResult Create([Bind(Include = "id,fullname,email,password,profil_picture,bio")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
コード例 #2
0
        public ActionResult Create([Bind(Include = "id,username,password")] Admin admin)
        {
            if (ModelState.IsValid)
            {
                db.Admins.Add(admin);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(admin));
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "id,kateqoriya_name")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
コード例 #4
0
ファイル: SourcesController.cs プロジェクト: KamranG12/admins
        public ActionResult Create([Bind(Include = "id,title,text,date,read_count,user_id,kateqoriya_id")] Source source)
        {
            if (ModelState.IsValid)
            {
                db.Sources.Add(source);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.user_id = new SelectList(db.Users, "id", "fullname", source.user_id);
            return(View(source));
        }
コード例 #5
0
        public ActionResult Create([Bind(Include = "id,comment1,user_id,topic_id")] Comment comment)
        {
            if (ModelState.IsValid)
            {
                db.Comments.Add(comment);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.topic_id = new SelectList(db.Sources, "id", "title", comment.topic_id);
            ViewBag.user_id  = new SelectList(db.Users, "id", "fullname", comment.user_id);
            return(View(comment));
        }
コード例 #6
0
        public ActionResult Create([Bind(Include = "id,like_count,dislike_count,user_id,topic_id")] Review review)
        {
            if (ModelState.IsValid)
            {
                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.topic_id = new SelectList(db.Sources, "id", "title", review.topic_id);
            ViewBag.user_id  = new SelectList(db.Users, "id", "fullname", review.user_id);
            return(View(review));
        }
コード例 #7
0
        public ActionResult Create([Bind(Include = "id,kateqoriya_id,topic_id")] RelCatAndSor relCatAndSor)
        {
            if (ModelState.IsValid)
            {
                db.RelCatAndSors.Add(relCatAndSor);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.kateqoriya_id = new SelectList(db.Categories, "id", "kateqoriya_name", relCatAndSor.kateqoriya_id);
            ViewBag.topic_id      = new SelectList(db.Sources, "id", "title", relCatAndSor.topic_id);
            return(View(relCatAndSor));
        }
コード例 #8
0
ファイル: HomeController.cs プロジェクト: palljuk/ASP-NET-MVC
        public ActionResult Index(FormCollection input)
        {
            StreamReader sr   = new StreamReader(Request.InputStream);
            string       json = sr.ReadToEnd();
            Name         name = JsonConvert.DeserializeObject <Name>(json);

            FirstProjectEntities entities = new FirstProjectEntities();
            SafetyBriefings      s        = new SafetyBriefings();

            s.CustomerName = name.CustomerName;
            s.CreatedAt    = DateTime.Now;
            entities.SafetyBriefings.Add(s);
            entities.SaveChanges();


            return(View());
        }