Exemplo n.º 1
0
        public ActionResult Edit([Bind(Include = "IdInterview,Date,Name,Comment,Canceled,Suspended,Description,Completion,IdCampaign,Id")] Interview.Interview interview)
        {
            var b = Request.Form["Consultant"];

            interview.Id = b;
            if (ModelState.IsValid)
            {
                db.Entry(interview).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            var idcamp = interview.IdCampaign;

            var consultants =
                db.ConsultantCampaigns.Include(cc => cc.ApplicationUsers)
                .Where(cc => cc.IdCampaign == idcamp)
                .Where(z => z.ApplicationUsers.Roles.Select(y => y.RoleId)
                       .Contains("1f468580-90bc-4e5b-b959-73082975919e") ||
                       z.ApplicationUsers.Roles.Select(y => y.RoleId)
                       .Contains("1ede4f9a-6f89-4a52-b81d-9ab127beaccf"))
                .Select(x => new { Id = x.Id, FullName = x.ApplicationUsers.FirstName + " " + x.ApplicationUsers.LastName });;

            ViewBag.Consultant = new SelectList(consultants, "Id", "FullName", interview.Id);

            ViewBag.IdCampaign = db.Campaigns.Single(c => c.IdCampaign == idcamp).Name;

            int year = (DateTime.Now.Year) - 1;

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

            return(View(interview));
        }
Exemplo n.º 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);
     //db.Interviews.Remove(interview); // Soft delete
     interview.Deleted = true;
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
Exemplo n.º 3
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;
                if (Command == "Create")
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(RedirectToAction("Index", "ConductInterview", new { idinterview = interview.IdInterview }));
                }
            }
            //ViewBag.Id = new SelectList(db.Users, "Id", "FullName", interview.Id);
            //var idfirm = db.Campaigns.Find(idcampaign).ApplicationUsers.IdFirm;
            //ViewBag.Consultant = new SelectList(db.Users.Where(u => u.IdFirm == idfirm), "Id", "FullName");
            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);
            //ViewBag.IdQuestionnaire = new SelectList(db.Questionnaires, "IdQuestionnaire", "Name", interview.Campaign.IdQuestionnaire);

            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 };

            ViewBag.Candidates = new MultiSelectList(candidates, "IdCandidate", "FullName");

            return(View(interview));
        }
Exemplo n.º 4
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));
        }
Exemplo n.º 5
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 }));
        }
Exemplo n.º 6
0
        public ActionResult Edit([Bind(Include = "IdInterview,Date,Name,Comment,Canceled,Suspended,Description,Completion,IdCampaign")] Interview.Interview interview)
        {
            var b = Request.Form["Consultant"];

            interview.Id = b;
            if (ModelState.IsValid)
            {
                db.Entry(interview).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            var idcamp = interview.IdCampaign;

            //var idfirm = db.Campaigns.Find(idcamp).ApplicationUsers.IdFirm;
            //ViewBag.Consultant = new SelectList(db.Users.Where(u => u.IdFirm == idfirm), "Id", "FullName", interview.Id);
            ViewBag.Consultant = new SelectList(db.ConsultantCampaigns.Include(cc => cc.ApplicationUsers).Where(cc => cc.IdCampaign == interview.IdCampaign).Select(cc => cc.ApplicationUsers), "Id", "FullName", interview.Id);
            ViewBag.IdCampaign = new SelectList(db.Campaigns.Where(c => c.Deleted == false), "IdCampaign", "Name", interview.IdCampaign);
            return(View(interview));
        }