public ActionResult DeleteConfirmed(int id) { CompletedTraining completedTraining = db.CompletedTrainings.Find(id); db.CompletedTrainings.Remove(completedTraining); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "completedTrainingID,volunteerID,volunteerTrainingID,cmpTrnDate,cmpTrnComments")] CompletedTraining completedTraining) { if (ModelState.IsValid) { db.Entry(completedTraining).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(completedTraining)); }
public ActionResult Create([Bind(Include = "completedTrainingID,volunteerID,volunteerTrainingID,cmpTrnDate,cmpTrnComments")] CompletedTraining completedTraining) { if (ModelState.IsValid) { db.CompletedTrainings.Add(completedTraining); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(completedTraining)); }
// GET: CompletedTraining/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CompletedTraining completedTraining = db.CompletedTrainings.Find(id); if (completedTraining == null) { return(HttpNotFound()); } return(View(completedTraining)); }
public ActionResult Form(CompletedTraining objcom, List <int> Attendess, List <int> Unattendess) //, List<string> LAttendess, List<string> LUnattendess) { try { string ServerName = AppValue.GetFromMailAddress("ServerName"); DSRCManagementSystemEntities1 objdb = new DSRCManagementSystemEntities1(); int count = Attendess.Count(); int count1 = Unattendess.Count(); DSRCManagementSystem.TrainingCompletion obj = new DSRCManagementSystem.TrainingCompletion(); List <string> MailIds = new List <string>(); List <string> Unmailids = new List <string>(); int?userid = int.Parse(Session["UserID"].ToString()); int?instructorid = objdb.Trainings.Where(x => x.TrainingId == objcom.TrainingId).Select(o => o.InstructorId).FirstOrDefault(); int?trainingid = objcom.TrainingId; // var nominee = Null; Session["Instructorid"] = instructorid; int?level = objdb.Trainings.Where(x => x.InstructorId == instructorid).Select(o => o.LevelId).FirstOrDefault(); var value = objdb.TrainingWeightages.Where(x => x.LevelId == level).Select(o => o.Trainee).FirstOrDefault(); string Feedbacksenton = DateTime.Now.ToShortDateString(); var nominee1 = objdb.TrainingNominations.Where(x => x.TrainingId == trainingid).Select(o => o).ToList(); nominee1.ForEach(o => o.CompletionFlag = false); objdb.SaveChanges(); foreach (int Eid in Attendess) { // var EId1 = Convert.ToString(Eid); // var EmpID =""; // if (EId1.Length == 1) // { // EmpID = "0000" + EId1; // } // if (EId1.Length == 2) // { // EmpID = "000" + EId1; // } // if (EId1.Length == 3) // { // EmpID = "00" + EId1; // } // if (EId1.Length == 4) // { // EmpID = "0" + EId1; // } // if (EId1.Length == 5) // { // EmpID = EId1; // } //if (EId1.Length == 1) // { // EmpID = "0000" + EId1; // } // if (EId1.Length == 1) // { // EmpID = "0000" + EId1; // } // var nominee = objdb.TrainingNominations.Where(x => x.TrainingId == trainingid && x.EmpId == EmpID).Select(o => o).FirstOrDefault(); if (Eid != 0) { var nominee = objdb.TrainingNominations.Where(x => x.TrainingId == trainingid && x.UserId == Eid).Select(o => o).FirstOrDefault(); if (value != null) { nominee.Score = Convert.ToInt32(value); objdb.SaveChanges(); } // string EMPID = Convert.ToString(Eid); //if (EMPID.Length == 4) //{ // EMPID = "0" + EMPID; //} //var user = objdb.Users.FirstOrDefault(o => o.EmpID == ).UserID; // var user = objdb.Users.Where(x => x.EmpID == EmpID).Select(x => x.UserID).FirstOrDefault(); var user = objdb.Users.Where(x => x.UserID == Eid).Select(x => x.UserID).FirstOrDefault(); // To avoid duplicate trainingID and UserID combination in training feedback calculation. var CheckUser = objdb.TrainingFeedBackCalcs.FirstOrDefault(o => o.TrainingId == nominee.TrainingId && o.UserId == user); if (CheckUser == null) { var RequestToFeedback = new TrainingFeedBackCalc { TrainingId = nominee.TrainingId, UserId = user, ChoiceTopic = 0, PgmRelevance = 0, ContentAmt = 0, AdequacyLearning = 0, AdequacyPreparation = 0, ExampleDemo = 0, ContentPresented = 0, TimeMaintanence = 0, FacultyQuality = 0, PgmUseful = false, LearntInPgm = "Not given yet", Comments = "Not given yet", FeedBackSentOn = Convert.ToDateTime(Feedbacksenton), Flag = false }; objdb.TrainingFeedBackCalcs.AddObject(RequestToFeedback); objdb.SaveChanges(); } } else { } } foreach (int UEid in Unattendess) { //if (UEid != 0) //{ // var EmpID = Convert.ToString(UEid); // if (EmpID.Length == 1) // { // EmpID = "0000" + EmpID; // } // if (EmpID.Length == 2) // { // EmpID = "000" + EmpID; // } // if (EmpID.Length == 3) // { // EmpID = "00" + EmpID; // } // if (EmpID.Length == 4) // { // EmpID = "0" + EmpID; // } //if (EmpID.Length == 5) //{ // EmpID = EmpID; //} //var nominee2 = objdb.TrainingNominations.Where(x => x.TrainingId == trainingid && x.EmpId == UEid).Select(o => o).FirstOrDefault(); if (UEid != 0) { if (value != null) { var nominee2 = objdb.TrainingNominations.Where(x => x.TrainingId == trainingid && x.UserId == UEid).Select(o => o).FirstOrDefault(); nominee2.Score = -(Convert.ToInt32(value)); objdb.SaveChanges(); } //} int id = Convert.ToInt32(trainingid); var RequestToFeedbackAgg = new TrainingFeedbackAggregate { TrainingId = id, TopicRating = 0, RelevanceRating = 0, CntAmtRating = 0, LearnRating = 0, PrepareRating = 0, EgDemoRating = 0, CntPresentRating = 0, TimeRating = 0, QualityRating = 0, ContentRating = 0, PresentRating = 0, FacultyQRating = 0, OverAllRating = 0, No_Of_Attendees = 0 }; objdb.TrainingFeedbackAggregates.AddObject(RequestToFeedbackAgg); objdb.SaveChanges(); } } /******In trainings after submitting completed the status is changed as Feedback pending not as completed. * dont change this status will effect on worklist mand Manage training*********/ var valuefed = objdb.Trainings.Where(x => x.TrainingId == trainingid).Select(o => o).FirstOrDefault(); valuefed.StatusId = 3; objdb.SaveChanges(); string temp = ""; foreach (var num in Attendess) { temp += num + ","; } string temp1 = ""; foreach (var num1 in Unattendess) { temp1 += num1 + ","; } int u = Attendess.Count(); int v = Unattendess.Count(); DSRCManagementSystem.TrainingCompletion com = new DSRCManagementSystem.TrainingCompletion(); com.TrainingId = objcom.TrainingId; com.TrainingName = objcom.Name; com.Date = DateTime.Now; com.Attendece = obj.Attendece; if (objcom.upload == null) { com.Material = ""; objdb.SaveChanges(); } else { com.Material = objcom.upload; objdb.SaveChanges(); } com.Count = u; com.IsActive = false; objdb.AddToTrainingCompletions(com); objdb.SaveChanges(); int empid; for (int i = 0; i < count; i++) { //empid = Convert.ToString(Attendess[i]); // empid = "0" + empid; // var Mail = objdb.Users.Where(x => x.EmpID == empid).Select(o => o.EmailAddress).FirstOrDefault(); empid = Attendess[i]; var Mail = objdb.Users.Where(x => x.UserID == empid).Select(o => o.EmailAddress).FirstOrDefault(); MailIds.Add(Mail); } for (int j = 0; j < count1; j++) { empid = Unattendess[j]; // if (empid.Length == 4) // empid = "0" + empid; // var Mail = objdb.Users.Where(x => x.EmpID == empid).Select(o => o.EmailAddress).FirstOrDefault(); var Mail = objdb.Users.Where(x => x.UserID == empid).Select(o => o.EmailAddress).FirstOrDefault(); Unmailids.Add(Mail); } int k = MailIds.Count(); int l = Unmailids.Count(); var TrainingDetails = objdb.Trainings.FirstOrDefault(o => o.TrainingId == trainingid); string Instructor = objdb.Users.Where(o => o.UserID == instructorid).Select(o => o.FirstName + " " + (o.LastName ?? "")).FirstOrDefault(); string completion = objcom.upload; System.Web.HttpContext.Current.Application["Training"] = trainingid.ToString(); int c = Convert.ToInt32(System.Web.HttpContext.Current.Application["Training"]); DateTime?d1 = objdb.Trainings.FirstOrDefault(o => o.TrainingId == trainingid).ScheduledDate; DateTime d2 = Convert.ToDateTime(d1); string d = d2.ToShortDateString(); // string ServerName = WebConfigurationManager.AppSettings["SeverName"]; var logo = CommonLogic.getLogoPath(); if (Unmailids == null) // addedd on 10.10 { var check = objdb.EmailTemplates.Where(x => x.TemplatePurpose == "Training Absentees").Select(o => o.EmailTemplateID).FirstOrDefault(); var folder = objdb.EmailTemplates.Where(o => o.TemplatePurpose == "Training Absentees").Select(x => x.TemplatePath).FirstOrDefault(); if ((check != null) && (check != 0)) { var objUnAttendees = (from p in objdb.EmailPurposes.Where(x => x.EmailPurposeName == "Training Absentees") join q in objdb.EmailTemplates on p.EmailTemplateID equals q.EmailTemplateID select new DSRCManagementSystem.Models.Email { To = p.To, CC = p.CC, BCC = p.BCC, Subject = p.Subject, Template = q.TemplatePath }).FirstOrDefault(); var company = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault(); string TemplatePathUnAttendees = Server.MapPath(objUnAttendees.Template); string htmlUnAttendees = System.IO.File.ReadAllText(TemplatePathUnAttendees); htmlUnAttendees = htmlUnAttendees.Replace("#TrainingId", trainingid.ToString()); htmlUnAttendees = htmlUnAttendees.Replace("#TrainingName", TrainingDetails.TrainingName); htmlUnAttendees = htmlUnAttendees.Replace("#ScheduledDate", d); htmlUnAttendees = htmlUnAttendees.Replace("#start", TrainingDetails.StartTime); htmlUnAttendees = htmlUnAttendees.Replace("#end", TrainingDetails.EndTime); htmlUnAttendees = htmlUnAttendees.Replace("#Instructor", Instructor); htmlUnAttendees = htmlUnAttendees.Replace("#ServerName", ServerName); htmlUnAttendees = htmlUnAttendees.Replace("#CompanyName", company); if (ServerName != "http://*****:*****@dsrc.co.in"); //MailIdss.Add("*****@*****.**"); //MailIdss.Add("*****@*****.**"); //MailIdss.Add("*****@*****.**"); //MailIdss.Add("*****@*****.**"); //MailIdss.Add("*****@*****.**"); //MailIdss.Add("*****@*****.**"); //string EmailAddress = ""; //foreach (string mail in MailIdss) //{ // EmailAddress += mail + ","; //} //EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1); // var logo = objdb.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault(); // DsrcMailSystem.MailSender.LD(null, objUnAttendees.Subject + " - Test Mail Please Ignore", null, htmlUnAttendees + " - Testing Plaese ignore", "*****@*****.**", MailIdss, "Test-L&[email protected]", "*****@*****.**", Server.MapPath(logo.AppValue.ToString())); DsrcMailSystem.MailSender.LD(null, objUnAttendees.Subject + " - Test Mail Please Ignore", null, htmlUnAttendees + " - Testing Plaese ignore", "*****@*****.**", MailIdss, "Test-L&[email protected]", "*****@*****.**", Server.MapPath(logo.ToString())); } else { //var logo = objdb.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault(); // DsrcMailSystem.MailSender.LD(null, objUnAttendees.Subject, null, htmlUnAttendees, "*****@*****.**", Unmailids, "L&[email protected]", "*****@*****.**", Server.MapPath(logo.AppValue.ToString())); DsrcMailSystem.MailSender.LD(null, objUnAttendees.Subject, null, htmlUnAttendees, "*****@*****.**", Unmailids, "L&[email protected]", "*****@*****.**", Server.MapPath(logo.ToString())); } } else { ExceptionHandlingController.TemplateMissing("Training Absentees", folder, ServerName); } } // addede on 10/10 var checks = objdb.EmailTemplates.Where(x => x.TemplatePurpose == "Completion").Select(o => o.EmailTemplateID).FirstOrDefault(); var folders = objdb.EmailTemplates.Where(o => o.TemplatePurpose == "Completion").Select(x => x.TemplatePath).FirstOrDefault(); if ((checks != null) && (checks != 0)) { var objCompletion = (from p in objdb.EmailPurposes.Where(x => x.EmailPurposeName == "Completion") join q in objdb.EmailTemplates on p.EmailTemplateID equals q.EmailTemplateID select new DSRCManagementSystem.Models.Email { To = p.To, CC = p.CC, BCC = p.BCC, Subject = p.Subject, Template = q.TemplatePath }).FirstOrDefault(); var objcompany = objdb.Master_ApplicationSettings.Where(x => x.AppKey == "Company Name").Select(o => o.AppValue).FirstOrDefault(); string TemplatePathCompletion = Server.MapPath(objCompletion.Template); string htmlCompletion = System.IO.File.ReadAllText(TemplatePathCompletion); htmlCompletion = htmlCompletion.Replace("#trainingname", objcom.Name); htmlCompletion = htmlCompletion.Replace("#scheduleddate", d); htmlCompletion = htmlCompletion.Replace("#ServerName", ServerName); htmlCompletion = htmlCompletion.Replace("#CompanyName", objcompany); if (ServerName != "http://*****:*****@dsrc.co.in"); //MailIdss.Add("*****@*****.**"); //MailIdss.Add("*****@*****.**"); //MailIdss.Add("*****@*****.**"); //MailIdss.Add("*****@*****.**"); //MailIdss.Add("*****@*****.**"); //MailIdss.Add("*****@*****.**"); //string EmailAddress = ""; //foreach (string mail in MailIdss) //{ // EmailAddress += mail + ","; //} //EmailAddress = EmailAddress.Remove(EmailAddress.Length - 1); //var logo = objdb.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault(); // DsrcMailSystem.MailSender.LD(null, objCompletion.Subject + " - Test Mail Please Ignore", null, htmlCompletion + " - Testing Plaese ignore", "*****@*****.**", MailIds , "Test-L&[email protected]", "*****@*****.**", Server.MapPath(logo.AppValue.ToString())); DsrcMailSystem.MailSender.LD(null, objCompletion.Subject + " - Test Mail Please Ignore", null, htmlCompletion + " - Testing Plaese ignore", "*****@*****.**", Mailidss, "Test-L&[email protected]", "*****@*****.**", Server.MapPath(logo.ToString())); } else { //var logo = objdb.Master_ApplicationSettings.Where(x => x.AppID == 7).Select(x => x).FirstOrDefault(); // DsrcMailSystem.MailSender.LD(null, objCompletion.Subject, null, htmlCompletion, "*****@*****.**", MailIds, "L&[email protected]", "*****@*****.**", Server.MapPath(logo.AppValue.ToString())); DsrcMailSystem.MailSender.LD(null, objCompletion.Subject, null, htmlCompletion, "*****@*****.**", MailIds, "L&[email protected]", "*****@*****.**", Server.MapPath(logo.ToString())); } } else { ExceptionHandlingController.TemplateMissing("Completion", folders, ServerName); } } catch (Exception Ex) { string actionName = this.ControllerContext.RouteData.Values["action"].ToString(); string controllerName = this.ControllerContext.RouteData.Values["controller"].ToString(); ExceptionHandlingController.ExceptionDetails(Ex, actionName, controllerName); } return(Json(new { Result = "Success" }, JsonRequestBehavior.AllowGet)); }