Пример #1
0
        public ActionResult Create([Bind(Include = "IdInterview,Date,Name,Comment,Canceled,Suspended,Description,Completion,Id,IdCampaign")] Interview.Interview interview, string Command)
        {
            var idcampaign = interview.IdCampaign;

            if (ModelState.IsValid)
            {
                var c = Request.Form["Candidates"];
                if (c != null)
                {
                    Array candidats = c.Split(new[] { ',' });
                    foreach (var i in from string s in candidats select new Interviewee {
                        IdInterview = interview.IdInterview, IdCandidate = int.Parse(s)
                    })
                    {
                        db.Interviewees.Add(i);
                    }
                }
                interview.Completion = 0;
                interview.Suspended  = false;
                interview.Canceled   = false;
                db.Interviews.Add(interview);
                db.SaveChanges();
                //idcampaign = db.Interviews.Find(interview.IdInterview).IdCampaign;
                ConductInterviewController cic = new ConductInterviewController();
                cic.SaveCoverageCompletion(idcampaign);

                return(Command == "Create" ? RedirectToAction("Details", "Campaigns", new { id = idcampaign })
                    : RedirectToAction("Index", "ConductInterview", new { idinterview = interview.IdInterview }));
            }
            ViewBag.Consultant = new SelectList(db.ConsultantCampaigns.Include(cc => cc.ApplicationUsers)
                                                .Where(cc => cc.IdCampaign == idcampaign)
                                                .Select(cc => cc.ApplicationUsers).ToList(), "Id", "FullName");
            ViewBag.IdCampaign = new SelectList(db.Campaigns.Where(c => c.Deleted == false), "IdCampaign", "Name", interview.IdCampaign);

            var candidates = from cc in db.CandidateCampaigns
                             join c in db.Candidates on cc.IdCandidate equals c.IdCandidate
                             where cc.IdCampaign == idcampaign
                             orderby c.LastName
                             select new { IdCandidate = c.IdCandidate, FullName = c.FirstName + " " + c.LastName + " - " + c.Function };

            ViewBag.Candidates = new MultiSelectList(candidates, "IdCandidate", "FullName");
            int year = (DateTime.Now.Year) - 1;

            ViewBag.MinDateDay = "" + DateTime.Now.Day + "/" + DateTime.Now.Month + "/" + year;

            return(View(interview));
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            //foreach (Answer a in db.Answers.Where(x => x.IdInterview == id)) // Soft delete
            //{
            //    db.Answers.Remove(a);
            //}
            Interview.Interview interview = db.Interviews.Find(id);
            var idcampaign = interview.IdCampaign;

            //db.Interviews.Remove(interview); // Soft delete
            interview.Deleted = true;
            db.SaveChanges();
            var cic = new ConductInterviewController();

            cic.SaveCoverageCompletion(idcampaign);

            return(RedirectToAction("Details", "Campaigns", new { id = interview.IdCampaign }));
        }