public ActionResult Create([Bind(Include = "TrainingId,TrainerName,EventName,Description,TrainingTime")] FarmersTraining farmersTraining)
        {
            if (ModelState.IsValid)
            {
                db.FarmersTrainings.Add(farmersTraining);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(farmersTraining));
        }
Example #2
0
        public ActionResult Create([Bind(Include = "keywordId,keyword1")] Keyword keyword)
        {
            if (ModelState.IsValid)
            {
                db.Keywords.Add(keyword);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(keyword));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "chairId")] Chair chair)
        {
            if (ModelState.IsValid)
            {
                db.Chairs.Add(chair);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.chairId = new SelectList(db.Users, "userId", "name", chair.chairId);
            return(View(chair));
        }
Example #4
0
        public ActionResult Create([Bind(Include = "conferenceId,beginDate,endDate,kindOfPaperTask,numOfReviewers,topic,chairId")] Conference conference)
        {
            if (ModelState.IsValid)
            {
                db.Conferences.Add(conference);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.chairId = new SelectList(db.Chairs, "chairId", "chairId", conference.chairId);
            return(View(conference));
        }
Example #5
0
        public ActionResult Create([Bind(Include = "authorId")] Author author)
        {
            if (ModelState.IsValid)
            {
                db.Authors.Add(author);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.authorId = new SelectList(db.Users, "userId", "name", author.authorId);
            return(View(author));
        }
Example #6
0
        public ActionResult Create([Bind(Include = "reviewId,reviewDate,rating,reviewDesc,reviewerId,paperId")] Review review)
        {
            if (ModelState.IsValid)
            {
                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.paperId    = new SelectList(db.Papers, "paperId", "title", review.paperId);
            ViewBag.reviewerId = new SelectList(db.Reviewers, "reviewerId", "reviewerId", review.reviewerId);
            return(View(review));
        }
Example #7
0
        public ActionResult Create([Bind(Include = "reviewerId,keywordId")] Reviewer reviewer)
        {
            if (ModelState.IsValid)
            {
                db.Reviewers.Add(reviewer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }


            ViewBag.reviewerId = new SelectList(db.Users, "userId", "name", reviewer.reviewerId);
            return(View(reviewer));
        }
Example #8
0
        public ActionResult Create([Bind(Include = "paperId,title,paperAbstract,content,keywordList,publishDate,status,finalDecision,paperType,conferenceId,authorId")] Paper paper)
        {
            if (ModelState.IsValid)
            {
                db.Papers.Add(paper);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.authorId     = new SelectList(db.Authors, "authorId", "authorId", paper.authorId);
            ViewBag.conferenceId = new SelectList(db.Conferences, "conferenceId", "kindOfPaperTask", paper.conferenceId);

            return(View(paper));
        }
Example #9
0
        public ActionResult Create([Bind(Include = "userId,name,userType")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.userId = new SelectList(db.Authors, "authorId", "authorId", user.userId);
            ViewBag.userId = new SelectList(db.Chairs, "chairId", "chairId", user.userId);
            ViewBag.userId = new SelectList(db.Reviewers, "reviewerId", "reviewerId", user.userId);
            return(View(user));
        }
Example #10
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            CMS db = new CMS();

            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    Email = model.Email, UserName = model.userName
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");


                    User users = new Models.User
                    {
                        userId   = user.Id,
                        name     = user.UserName,
                        userType = model.UserRoles,
                    };

                    db.Users.Add(users);

                    if (model.UserRoles == "Chair")
                    {
                        UserManager.AddToRole(user.Id, "Chair");

                        Chair chair = new Chair
                        {
                            chairId = user.Id,//is my model's user id
                        };
                        db.Chairs.Add(chair);
                    }
                    else
                    if (model.UserRoles == "Reviewer")
                    {
                        UserManager.AddToRole(user.Id, "Reviewer");
                        Reviewer reviewer = new Reviewer
                        {
                            reviewerId = user.Id,
                        };
                        db.Reviewers.Add(reviewer);
                    }
                    else
                    if (model.UserRoles == "Author")
                    {
                        UserManager.AddToRole(user.Id, "Author");
                        Author author = new Author
                        {
                            authorId = user.Id,
                        };
                        db.Authors.Add(author);
                    }

                    db.SaveChanges();

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }