Esempio n. 1
0
        private void UpdateInterview()
        {
            using (ModelContext db = new ModelContext())
            {
                int interviewId;
                if (!Int32.TryParse(TextBox_Intvw_ID.Text, out interviewId))
                {
                    throw new ArgumentException($"Value '{TextBox_Intvw_ID.Text}' in Interview ID TextBox could not be parsed.");
                }

                var interviewDb = db.Interviews.FirstOrDefault(c => c.Id == interviewId);
                if (interviewDb == null)
                {
                    throw new ArgumentException($"No Interview found with ID #{interviewId}.");
                }

                Dictionary <string, string> newInterviewFields = LoadInterviewFieldValues();
                FieldValidator.CheckInterviewFields(newInterviewFields);

                interviewDb.Type           = newInterviewFields["Type"];
                interviewDb.Method         = newInterviewFields["Method"];
                interviewDb.Interviewer    = newInterviewFields["Interviewer"];
                interviewDb.DateScheduled  = DateTime.Parse(newInterviewFields["Date"]);
                interviewDb.SkillsRequired = newInterviewFields["Skills"];
                interviewDb.Status         = newInterviewFields["Status"];
                interviewDb.Feedback       = newInterviewFields["Feedback"];
                interviewDb.Remarks        = newInterviewFields["Remarks"];

                db.SaveChanges();
                LoggingUtility.LogMessage($"Interview #{interviewDb.Id} successfully updated.");
            }
        }
Esempio n. 2
0
        protected void Button_Add_Interview_Click(object sender, EventArgs e)
        {
            try
            {
                using (ModelContext db = new ModelContext())
                {
                    int      submissionSlno, consultantID;
                    DateTime date;

                    submissionSlno = Convert.ToInt32(HiddenField_Submission_SLNO.Value);
                    consultantID   = db.Consultants.FirstOrDefault(c => c.LastName.Equals(TextBox_Intvw_Constultant.Text)).Id;


                    Dictionary <string, string> interviewValues = LoadInterviewFieldValues();

                    FieldValidator.CheckInterviewFields(interviewValues);

                    date = DateTime.Parse(interviewValues["Date"]);
                    var newInterview = new Models.Interviews
                    {
                        SubmissionSlno = submissionSlno,
                        ConsultantId   = consultantID,
                        Type           = interviewValues["Type"],
                        Method         = interviewValues["Method"],
                        Interviewer    = interviewValues["Interviewer"],
                        SkillsRequired = interviewValues["Skills"],
                        Status         = interviewValues["Status"],
                        Feedback       = interviewValues["Feedback"],
                        Remarks        = interviewValues["Remarks"],
                        DateScheduled  = date
                    };
                    db.Interviews.Add(newInterview);
                    db.SaveChanges();
                    LoggingUtility.LogMessage($"New Interview #{newInterview.Id} successfully added.");
                }
            }
            catch (Exception ex) { handleException(ex, sender.ToString()); }
            Response.Redirect($"~/Pages/ViewAllSubmissions.aspx?Id={ConsultantId.Value}");
        }