public ActionResult Create([Bind(Include = "reviewId,review1,status,interviewDate")] Review review)
        {
            if (ModelState.IsValid)
            {
                review.dt_created    = DateTime.Now;
                review.applicationId = (int)Session["applicationId"];
                review.cd_creater    = (int)Session["userId"];

                Application application = db.Applications.Find(review.applicationId);
                review.userId  = application.userId;
                review.paperId = application.paperId;
                review.jobId   = application.jobId;

                application.status = review.status;

                db.Reviews.Add(review);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.applicationId = new SelectList(db.Applications, "applicationId", "status", review.applicationId);
            ViewBag.paperId       = new SelectList(db.InterviewQuestionPapers, "paperId", "answer1", review.paperId);
            ViewBag.jobId         = new SelectList(db.Jobs, "jobId", "applicantList", review.jobId);
            ViewBag.userId        = new SelectList(db.Users, "userId", "name", review.userId);
            return(View(review));
        }
Exemplo n.º 2
0
        public ActionResult Create(User user)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    // Check for email is already in use or not.
                    bool alreadyexists = false;

                    // Iterate in Database
                    foreach (User u in db.Users.ToList())
                    {
                        if (u.email.Equals(user.email))
                        {
                            // If already in use break the loop and change match data.
                            alreadyexists = true;
                            break;
                        }
                    }

                    if (alreadyexists)
                    {
                        // In case of duplicate emails, produce an error message and return back to register page.
                        ModelState.AddModelError(string.Empty, "This email already in use.");
                        return(View());
                    }

                    if (Session["userName"] == null)
                    {
                        // If create accesed by register.
                        user.BoolValue = false;
                    }

                    // Creating time log stored.
                    user.dt_created = DateTime.Now;
                    db.Users.Add(user);
                    db.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    throw;
                }
                return(RedirectToAction("Index", "Home", null));
            }

            return(View(user));
        }
Exemplo n.º 3
0
        public ActionResult Create([Bind(Include = "jobId,applicantList,jobName,applicationStart,applicationFinish,SelectedCategories,questionNumber")] Job job)
        {
            if (ModelState.IsValid)
            {
                job.categories = string.Join(",", job.SelectedCategories);
                db.Jobs.Add(job);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(job));
        }
Exemplo n.º 4
0
        public ActionResult Create([Bind(Include = "category, question1")] Question question)
        {
            if (ModelState.IsValid)
            {
                question.cd_creater = (int)Session["userId"];
                question.dt_created = DateTime.Now;
                db.Questions.Add(question);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(question));
        }
Exemplo n.º 5
0
        public ActionResult Create([Bind(Include = "paperId,applicationId,userId,jobId,cd_creater,dt_created,cd_modifier,dt_modified")] InterviewQuestionPaper interviewQuestionPaper)
        {
            if (ModelState.IsValid)
            {
                db.InterviewQuestionPapers.Add(interviewQuestionPaper);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.applicationId = new SelectList(db.Applications, "applicationId", "applicationId", interviewQuestionPaper.applicationId);
            ViewBag.userId        = new SelectList(db.Users, "userId", "name", interviewQuestionPaper.userId);
            return(View(interviewQuestionPaper));
        }
Exemplo n.º 6
0
 public ActionResult Create([Bind(Include = "categoryId,categoryName")] Category category)
 {
     if (Session["userName"] == null)
     {
         // If non user person wants to reach Edit page.
         return(RedirectToAction("NotAuthorized", "Home"));
     }
     if ((int)Session["isAdmin"] == 0)
     {
         return(RedirectToAction("NotAuthorized", "Home"));
     }
     if (ModelState.IsValid)
     {
         db.Categories.Add(category);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Exemplo n.º 7
0
        public ActionResult Create([Bind(Include = "newId,header,text,imageFile,BoolValue,featuredList,dt_created,dt_modified,cd_creater,cd_modifier")] New @new)
        {
            if (Session["userName"] == null)
            {
                // If non user person wants to reach Edit page.
                return(RedirectToAction("NotAuthorized", "Home"));
            }
            if ((int)Session["isAdmin"] == 0)
            {
                return(RedirectToAction("NotAuthorized", "Home"));
            }
            if (ModelState.IsValid)
            {
                if (@new.imageFile != null && @new.imageFile.ContentLength > 0)
                {
                    string FileExtension = Path.GetExtension(@new.imageFile.FileName).ToUpper();

                    if (FileExtension == ".JPG" || FileExtension == ".PNG" || FileExtension == ".JPEG")
                    {
                        byte[] bytes;
                        using (BinaryReader br = new BinaryReader(@new.imageFile.InputStream))
                        {
                            bytes = br.ReadBytes(@new.imageFile.ContentLength);
                        }

                        @new.image = bytes;
                    }
                }

                @new.dt_created = DateTime.Now;
                @new.cd_creater = (int)Session["userId"];
                db.News.Add(@new);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(@new));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "applicationId,cvFile,paperId")] Application application)
        {
            if (ModelState.IsValid)
            {
                if (application.cvFile != null && application.cvFile.ContentLength > 0)
                {
                    string FileExtension = Path.GetExtension(application.cvFile.FileName).ToUpper();

                    if (FileExtension == ".PDF")
                    {
                        byte[] bytes;
                        using (BinaryReader br = new BinaryReader(application.cvFile.InputStream))
                        {
                            bytes = br.ReadBytes(application.cvFile.ContentLength);
                        }

                        application.cv = bytes;
                    }
                }
                application.userId = (int)Session["userId"];
                application.status = "Interview";
                User user = db.Users.Where(a => a.userId == (application.userId)).FirstOrDefault();
                application.dt_created = DateTime.Now;
                user.Applications.Add(application);

                application.jobId = (int)Session["jobId"];

                Job job = db.Jobs.Find(application.jobId);
                InterviewQuestionPaper paper = new InterviewQuestionPaper();


                int      totalQuestions  = (int)job.questionNumber;
                string[] categoriesArray = job.categories.Split(',');
                //var questionIds = db.Questions.OrderBy(h => Guid.NewGuid()).Select(c => c.questionId).Take(3).ToList();
                int[]      numbers      = new int[categoriesArray.Length];
                List <int> allquestions = new List <int>();

                for (int i = 0; i < totalQuestions; i++)
                {
                    numbers[i % (categoriesArray.Length)]++;
                }

                for (int i = 0; i < categoriesArray.Length; i++)
                {
                    int question    = int.Parse(categoriesArray[i]);
                    var list        = db.Questions.Where(a => a.category == question);
                    var questionIds = list.OrderBy(h => Guid.NewGuid()).Select(c => c.questionId).Take(numbers[i]).ToList();
                    allquestions.AddRange(questionIds);
                }

                paper.questionList = string.Join(",", allquestions);


                paper.userId     = application.userId;
                paper.jobId      = application.jobId;
                paper.dt_created = DateTime.Now;
                paper.cd_creater = application.userId;

                db.InterviewQuestionPapers.Add(paper);
                db.SaveChanges();

                application.paperId = paper.paperId;
                paper.applicationId = application.applicationId;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.userId = new SelectList(db.Users, "userId", "name", application.userId);
            return(View(application));
        }