public JsonResult LoadNominationApprovedDetailsForGrid(string dept = "", string date = "") { _repoResponse = new RepositoryResponse(); if (dept == "--Select--") { dept = ""; } if (date == "--Select--") { date = ""; } else if (!string.IsNullOrEmpty(date)) { string[] monthYear = date.Split(' '); string month = monthYear[0].Substring(0, 3); string year = monthYear[1]; date = month + "-" + year; } _nominationRepo = new NominationRepo(); string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString(); _repoResponse = _nominationRepo.LoadNominationForDH(_loggedInUserID, dept, date, "approved"); if (_repoResponse.success) { var _sa = new JsonSerializerSettings(); return(Json(_repoResponse.Data)); } else { return(Json(new { success = _repoResponse.success.ToString(), message = _repoResponse.message })); } }
public ActionResult assignEvaltorForNomination(DashboardModel model) { if (ModelState.IsValid) { _nominationRepo = new NominationRepo(); _repoResponse = new RepositoryResponse(); string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString(); _repoResponse = _nominationRepo.AssignEvalatorToNominationByTQCHead(model, _loggedInUserID); _loginRepo = new LoginRepo(); int _empSOMRole = int.Parse(System.Web.HttpContext.Current.Session["EmpSOMRole"].ToString()); int count = _loginRepo.getActionCounts(_loggedInUserID, _empSOMRole); HttpContext.Session["NotifyCount"] = count; return(Json(new { success = _repoResponse.success, message = _repoResponse.message })); } else { string _message = string.Empty; List <string> fieldOrder = new List <string>(new string[] { "UserName", "Password" }) .Select(f => f.ToLower()).ToList(); var _message1 = ModelState .Select(m => new { Order = fieldOrder.IndexOf(m.Key.ToLower()), Error = m.Value }) .OrderBy(m => m.Order) .SelectMany(m => m.Error.Errors.Select(e => e.ErrorMessage)).ToList(); _message = string.Join("<br/>", _message1); return(Json(new { success = false, message = _message })); } }
public ActionResult Save(NominationModel model, HttpPostedFileBase[] files) { string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString(); _repoResponse = new RepositoryResponse(); _nominationRepo = new NominationRepo(); if (string.IsNullOrEmpty(model.NominationID)) { _repoResponse = _nominationRepo.NominationRestrictionCount(_loggedInUserID); if (!_repoResponse.success) { return(Json(new { success = _repoResponse.success, message = _repoResponse.message })); } } if (ModelState.IsValid) { _loginRepo = new LoginRepo(); //FileUpload(files); _repoResponse = _nominationRepo.AddOrEditNominationDetails(_loggedInUserID, model); if (_repoResponse.success) { _loginRepo = new LoginRepo(); int _empSOMRole = int.Parse(System.Web.HttpContext.Current.Session["EmpSOMRole"].ToString()); int count = _loginRepo.getActionCounts(_loggedInUserID, _empSOMRole); HttpContext.Session["NotifyCount"] = count; return(Json(new { success = true, message = _repoResponse.message, Data = _repoResponse.Data })); } else { return(Json(new { success = false, message = _repoResponse.message, Data = _repoResponse.Data })); } } else { List <string> fieldOrder = new List <string>(new string[] { "UserName", "Password" }) .Select(f => f.ToLower()).ToList(); var _message1 = ModelState .Select(m => new { Order = fieldOrder.IndexOf(m.Key.ToLower()), Error = m.Value }) .OrderBy(m => m.Order) .SelectMany(m => m.Error.Errors.Select(e => e.ErrorMessage)).ToList(); _message = string.Join("<br/>", _message1); return(Json(new { success = false, message = _message })); } }
public ActionResult Reports(string month = "", string year = "") { nominationRepo = new NominationRepo(); repoResponse = new RepositoryResponse(); string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString(); repoResponse = nominationRepo.GetReportDetails(_loggedInUserID, month, year); if (repoResponse.success) { ParticipatedCount _model = new ParticipatedCount(); _model = repoResponse.Data; return(View(_model)); } return(Json(new { success = repoResponse.success, message = repoResponse.message })); }
public JsonResult GetEvaluatorDataByID(string Prefix) { _nominationRepo = new NominationRepo(); List <AutoCompleteBox> lstAutoCompleteBox = _nominationRepo.GetEvaltorDetailsForAutoCompleteBox(); var _empData = (from N in lstAutoCompleteBox where N.ID.ToLower().Contains(Prefix.ToLower()) select new { label = N.ID, val = N.Value }).Distinct(); return(Json(_empData, JsonRequestBehavior.AllowGet)); }
public JsonResult LoadDashboardDetailsForFilter(string dept = "", string fromDate = "", string toDate = "") { repoResponse = new RepositoryResponse(); if (dept == "--ALL--") { dept = ""; } if (string.IsNullOrEmpty(fromDate)) { fromDate = DateTime.Now.ToString("MMMM yyyy"); } else if (!string.IsNullOrEmpty(fromDate)) { string[] monthYear = fromDate.Split(' '); string month = monthYear[0].Substring(0, 3); string year = monthYear[1]; fromDate = month + "-" + year; } if (string.IsNullOrEmpty(toDate)) { toDate = DateTime.Now.ToString("MMMM yyyy"); } else if (!string.IsNullOrEmpty(toDate)) { string[] monthYear = toDate.Split(' '); string month = monthYear[0].Substring(0, 3); string year = monthYear[1]; toDate = month + "-" + year; } nominationRepo = new NominationRepo(); string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString(); repoResponse = nominationRepo.GetReportDetails(_loggedInUserID, dept, fromDate, toDate); if (repoResponse.success) { ParticipatedCount partModel = new ParticipatedCount(); partModel = repoResponse.Data; //var _sa = new JsonSerializerSettings(); //return Json(new { data = partModel }); return(Json(new { success = repoResponse.success, message = partModel })); } else { return(Json(new { success = repoResponse.success, message = repoResponse.message })); } }
//[ValidateAntiForgeryToken] public ActionResult FileUpload() { string nominationID = Request["NominationID"]; string fileNamesForDb = string.Empty; HttpFileCollectionBase files = Request.Files; for (int i = 0; i < files.Count; i++) { HttpPostedFileBase file = files[i]; string fname; // Checking for Internet Explorer if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { fname = file.FileName; } if (string.IsNullOrEmpty(fileNamesForDb)) { fileNamesForDb = fname; } else { fileNamesForDb = fileNamesForDb + ";" + fname; } string subPath = "~/Uploads/" + nominationID + "/"; bool exists = System.IO.Directory.Exists(subPath); if (!exists) { System.IO.Directory.CreateDirectory(Server.MapPath(subPath)); } fname = Path.Combine(Server.MapPath(subPath), fname); file.SaveAs(fname); } if (!string.IsNullOrEmpty(fileNamesForDb)) { _nominationRepo = new NominationRepo(); _nominationRepo.AddFileNameToNomination(nominationID, fileNamesForDb); } return(Json(new { success = true, message = "Your files uploaded successfully" })); }
public ActionResult Reject(NominationModel model) { _repoResponse = new RepositoryResponse(); _nominationRepo = new NominationRepo(); string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString(); _repoResponse = _nominationRepo.NominationFormDHOperations(_loggedInUserID, model, (int)NominationStatus.HoD_Reject); _loginRepo = new LoginRepo(); int _empSOMRole = int.Parse(System.Web.HttpContext.Current.Session["EmpSOMRole"].ToString()); int count = _loginRepo.getActionCounts(_loggedInUserID, _empSOMRole); HttpContext.Session["NotifyCount"] = count; return(Json(new { success = _repoResponse.success, message = _repoResponse.message })); }
public ActionResult NominationDataExport() { _repoResponse = new RepositoryResponse(); _nominationRepo = new NominationRepo(); string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString(); _repoResponse = _nominationRepo.LoadNomination(_loggedInUserID, ""); if (_repoResponse.success) { DataSet ds = Assistant.ToDataSet(_repoResponse.Data); string path = HostingEnvironment.MapPath("~/bin/Pdf/"); string fName = "SOM_NominationDetails_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".xlsx"; if (Assistant.DatasetToExcelExport(ds, path, fName, 5, "NominationDetails")) // 4th parameter is field Count { byte[] fileBytes = System.IO.File.ReadAllBytes(path + "" + fName); return(File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fName)); } } return(Json(new { success = _repoResponse.success, message = _repoResponse.message })); }
public RepositoryResponse AddOrEditStarOfMonth(StarOfMonthModel model, string loggedInuserID) { _nominationRepo = new NominationRepo(); baseModel = new RepositoryResponse(); try { string nomID = string.Empty; //string IPValue = string.Empty; Nomination dbNomModel = new Nomination(); using (objSOMEntities = new SOMEntities()) { //var config = objSOMEntities.Configurations.Where(r => r.Module == "SOM" && r.Type == "UPDATEIP" && r.IsActive == true).FirstOrDefault(); //IPValue = config.Value; var dbModel = objSOMEntities.StarOfTheMonths.Where(r => r.TransID == model.TransID).FirstOrDefault(); if (string.IsNullOrEmpty(model.SelectedNominationID)) { dbNomModel = objSOMEntities.Nominations.Where(r => r.NominationId == dbModel.NominationID).FirstOrDefault(); } else { dbNomModel = objSOMEntities.Nominations.Where(r => r.NominationId == model.SelectedNominationID.Replace("\r\n", "")).FirstOrDefault(); } if (dbModel == null) { nomID = dbNomModel.NominationId; dbModel = new StarOfTheMonth.DataBase.StarOfTheMonth(); dbModel.EmpId = int.Parse(dbNomModel.EmployeeNumber); dbModel.IsApproved = true; dbModel.IsDisplay = true; if (string.IsNullOrEmpty(model.Month)) { dbModel.Month = model.MonthFilter; } else { dbModel.Month = model.Month; } if (string.IsNullOrEmpty(model.Year)) { dbModel.Year = model.YearFilter; } else { dbModel.Year = model.Year; } dbModel.NominationID = dbNomModel.NominationId; dbModel.Description = dbNomModel.Idea; dbModel.ApprovedBy = int.Parse(loggedInuserID); dbModel.CreatedBy = int.Parse(loggedInuserID); //dbModel.CreatedDate = toISTDate(DateTime.Now); dbModel.ModifiedBy = int.Parse(loggedInuserID); // dbModel.ModifiedDate = toISTDate(DateTime.Now); objSOMEntities.StarOfTheMonths.Add(dbModel); objSOMEntities.SaveChanges(); baseModel = new RepositoryResponse { success = true, message = "Star of Month Declared Successfully", Data = "" }; } else { nomID = dbModel.NominationID; //dbModel.EmpId = int.Parse(model.EmpId); //dbModel.IsApproved = true; //dbModel.IsDisplay = true; //dbModel.Description = model.Description; dbModel.Month = model.MonthFilter; dbModel.Year = model.YearFilter; //dbModel.NominationID = model.NominationID; dbModel.CreatedBy = int.Parse(loggedInuserID); //dbModel.CreatedDate = DateTime.UtcNow; dbModel.ModifiedBy = int.Parse(loggedInuserID); //dbModel.ModifiedDate = DateTime.UtcNow; objSOMEntities.SaveChanges(); baseModel = new RepositoryResponse { success = true, message = "Star of Month Declared updated Successfully", Data = "" }; } if (dbNomModel != null) { dbNomModel.SOMComments = model.SOMComments; dbNomModel.SOMSubmittedDate = DateTime.Now.ToString("ddMMyyyy"); dbNomModel.SOMSignature = loggedInuserID; dbNomModel.Status = (int)NominationStatus.TQC_Declare_SOM; dbNomModel.ModifiedBy = loggedInuserID; objSOMEntities.SaveChanges(); } Evaluation evalDbModel = objSOMEntities.Evaluations.Where(r => r.NominationID == nomID && r.EvaluatorID != "").FirstOrDefault(); long HODId = _nominationRepo.GetReportingIDByEmpID(dbNomModel.EmployeeNumber); AuditLogModel objAuditLog = new AuditLogModel(); objAuditLog.CurrentStatus = NominationStatus.TQC_Declare_SOM; objAuditLog.EmployeeNumber = dbNomModel.EmployeeNumber; objAuditLog.IsNewAlert = true; objAuditLog.IsNotification = true; objAuditLog.DepartmentHeadID = HODId.ToString(); objAuditLog.TQCHeadID = loggedInuserID; objAuditLog.EvaluatorID = evalDbModel.EvaluatorID; objAuditLog.NominationID = nomID; objAuditLog.CreatedBy = loggedInuserID; _nominationRepo.AddEntryIntoAuditLog(objAuditLog); } //if (string.IsNullOrEmpty(IPValue) && IPValue == "true") //{ // AddOrEditStarOfMonth_IntranetPortal(model, loggedInuserID); //} } catch (Exception ex) { baseModel = new RepositoryResponse { success = false, message = ex.ToString() }; } return(baseModel); }
public RepositoryResponse AddOrEditStarOfMonth_IntranetPortal(StarOfMonthModel model, string loggedInuserID) { _nominationRepo = new NominationRepo(); baseModel = new RepositoryResponse(); try { string nomID = string.Empty; Nomination dbNomModel = new Nomination(); using (objSOMEntities = new SOMEntities()) using (objIPEntities = new IntranetPortalEntities()) { var dbModel = objIPEntities.StarOfTheMonths.Where(r => r.TransID == model.TransID).FirstOrDefault(); if (string.IsNullOrEmpty(model.SelectedNominationID)) { dbNomModel = objSOMEntities.Nominations.Where(r => r.NominationId == dbModel.NominationID).FirstOrDefault(); } else { dbNomModel = objSOMEntities.Nominations.Where(r => r.NominationId == model.SelectedNominationID.Replace("\r\n", "")).FirstOrDefault(); } if (dbModel == null) { nomID = dbNomModel.NominationId; dbModel = new StarOfTheMonth.DataBase.StarOfTheMonth(); dbModel.EmpId = int.Parse(dbNomModel.EmployeeNumber); dbModel.IsApproved = true; dbModel.IsDisplay = true; if (string.IsNullOrEmpty(model.Month)) { dbModel.Month = model.MonthFilter; } else { dbModel.Month = model.Month; } if (string.IsNullOrEmpty(model.Year)) { dbModel.Year = model.YearFilter; } else { dbModel.Year = model.Year; } dbModel.NominationID = dbNomModel.NominationId; dbModel.Description = dbNomModel.Idea; dbModel.CreatedBy = int.Parse(loggedInuserID); dbModel.ModifiedBy = int.Parse(loggedInuserID); objIPEntities.StarOfTheMonths.Add(dbModel); objIPEntities.SaveChanges(); baseModel = new RepositoryResponse { success = true, message = "Star of Month Details Added Successfully", Data = "" }; } else { nomID = dbModel.NominationID; dbModel.Month = model.MonthFilter; dbModel.Year = model.YearFilter; dbModel.CreatedBy = int.Parse(loggedInuserID); dbModel.ModifiedBy = int.Parse(loggedInuserID); objIPEntities.SaveChanges(); baseModel = new RepositoryResponse { success = true, message = "Star of Month Details updated Successfully", Data = "" }; } } } catch (Exception ex) { baseModel = new RepositoryResponse { success = false, message = ex.ToString() }; } return(baseModel); }
public RepositoryResponse AddorUpdateEvaluationData(EvaluationModel model, string _loggedInUserID, bool isSubmit) { baseModel = new RepositoryResponse(); try { using (objSOMEntities = new SOMEntities()) { Evaluation db = objSOMEntities.Evaluations.Where(r => r.ID == model.ID).FirstOrDefault(); if (db == null) { objSOMEntities.Evaluations.Add(ConvertEvaluation_Model2DB(model, _loggedInUserID, isSubmit)); objSOMEntities.SaveChanges(); if (isSubmit) { baseModel = new RepositoryResponse { success = true, message = "Evaluations Scroe Details Submitted to TQC Successfully" }; } else { baseModel = new RepositoryResponse { success = true, message = "Evaluations Scroe Details added Successfully" }; } } else { db.TotalScore = int.Parse(model.TotalScore); db.AheadOfPlan = model.AheadOfPlan; db.AsPerPlan = model.AsPerPlan; db.BasedOnInstruction = model.BasedOnInstruction; db.BreakthroughImprovement = model.BreakthroughImprovement; db.CoordiantionWithInTheDept = model.CoordiantionWithInTheDept; db.CoordinationWithAnotherFunction = model.CoordinationWithAnotherFunction; db.CoordinationWithMultipleFunctions = model.CoordinationWithMultipleFunctions; db.Delayed = model.Delayed; //db.EmployeeID = model.EmployeeID; db.NominationID = model.NominationID; //db.EvaluatorID = model.EvaluatorID; db.FollowedUp = model.FollowedUp; //db.ID = model.ID; db.Implemented = model.Implemented; db.ImplementedInAllApplicableAreas = model.ImplementedInAllApplicableAreas; db.ImplementedPartially = model.ImplementedPartially; db.ImprovementFromCurrentSituation = model.ImprovementFromCurrentSituation; db.IsActive = true; db.Participated = model.Participated; db.PreventionOfaFailure = model.PreventionOfaFailure; db.ProactiveIdeaGeneratedBySelf = model.ProactiveIdeaGeneratedBySelf; db.ReactiveIdeaDrivenBySituation = model.ReactiveIdeaDrivenBySituation; db.ScopeIdentified = model.ScopeIdentified; if (isSubmit) { db.Status = (int)NominationStatus.Evaluators_Assign_TQC; } else { db.Status = (int)NominationStatus.Evaluators_Save; } db.ModifiedBy = _loggedInUserID; objSOMEntities.SaveChanges(); if (isSubmit) { configRepo = new ConfigurationRepo(); bool result = configRepo.SendEmailUsingSOM_Evaluator_Assign_TQC(db.NominationID, _loggedInUserID); if (result) { baseModel = new RepositoryResponse { success = true, message = "Evaluations Scroe Details Submitted to TQC Successfully and Send Mail to TQC" }; } else { baseModel = new RepositoryResponse { success = true, message = "Evaluations Scroe Details Submitted to TQC Successfully. Unable to Send Mail to TQC" }; } } else { baseModel = new RepositoryResponse { success = true, message = "Evaluations Scroe Details updated Successfully" }; } } } using (objSOMEntities = new SOMEntities()) { if (isSubmit) { var nomDet = objSOMEntities.Nominations.Where(r => r.NominationId == model.NominationID).FirstOrDefault(); nomDet.Status = (int)NominationStatus.Evaluators_Assign_TQC; nomDet.ModifiedBy = _loggedInUserID; objSOMEntities.SaveChanges(); } } if (isSubmit) { nomRepo = new NominationRepo(); //Add entry into Audit Log AuditLogModel objAuditLog = new AuditLogModel(); objAuditLog.CurrentStatus = NominationStatus.Evaluators_Assign_TQC; objAuditLog.EmployeeNumber = model.EmployeeNumber; objAuditLog.IsNewAlert = true; objAuditLog.IsNotification = true; objAuditLog.NominationID = model.NominationID; objAuditLog.CreatedBy = _loggedInUserID; objAuditLog.EvaluatorID = _loggedInUserID; nomRepo.AddEntryIntoAuditLog(objAuditLog); Nomination _nomModel; using (objSOMEntities = new SOMEntities()) { _nomModel = objSOMEntities.Nominations.Where(r => r.NominationId == model.NominationID).FirstOrDefault(); } // Add entry into SOM StarOfMonthModel SOMmodel = new StarOfMonthModel(); SOMmodel.Month = _nomModel.SubmittedMonth; SOMmodel.Year = _nomModel.SubmittedYear; SOMmodel.Description = _nomModel.Idea; SOMmodel.EmpId = model.EmployeeNumber; SOMmodel.NominationID = model.NominationID; SOMmodel.IsDisplay = true; SOMmodel.IsApproved = true; SOMmodel.ApprovedBy = int.Parse(_loggedInUserID); SOMmodel.CreatedBy = int.Parse(_loggedInUserID); SOMmodel.CreatedDate = DateTime.Now; SOMmodel.ModifiedBy = int.Parse(_loggedInUserID); SOMmodel.ModifiedDate = DateTime.Now; starRepo = new StarOfMonthRepo(); //starRepo.AddOrEditStarOfMonth(SOMmodel, _loggedInUserID); } if (isSubmit) //Send Nomination Submit Details to DH { using (objSOMEntities = new SOMEntities()) { } } } catch (Exception ex) { baseModel = new RepositoryResponse { success = false, message = ex.ToString() }; } return(baseModel); }
public ActionResult Index(string dept = "", string fromDate = "", string toDate = "") { DashboardModel model = new DashboardModel(); ParticipatedCount partModel = new ParticipatedCount(); repoResponse = new RepositoryResponse(); nominationRepo = new NominationRepo(); loginRepo = new LoginRepo(); int _empSOMRole = int.Parse(System.Web.HttpContext.Current.Session["EmpSOMRole"].ToString()); string _dept = System.Web.HttpContext.Current.Session["UserDepartment"].ToString(); var monthFilter = loginRepo.GetMonthYearFilter(); var deptFilter = loginRepo.GetDepartmentDetails(); model.From_Nom_DateFilterlst = monthFilter; model.DeptFilterlst = deptFilter; if (dept == "--Select--") { dept = ""; } if (string.IsNullOrEmpty(fromDate)) { fromDate = DateTime.Now.ToString("MMMM yyyy"); } else if (!string.IsNullOrEmpty(fromDate)) { string[] monthYear = fromDate.Split(' '); string month = monthYear[0].Substring(0, 3); string year = monthYear[1]; fromDate = month + "-" + year; } if (string.IsNullOrEmpty(toDate)) { toDate = DateTime.Now.ToString("MMMM yyyy"); } else if (!string.IsNullOrEmpty(toDate)) { string[] monthYear = toDate.Split(' '); string month = monthYear[0].Substring(0, 3); string year = monthYear[1]; toDate = month + "-" + year; } string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString(); if (_empSOMRole == (int)SOMEmpRole.TQCHead) { } else if (string.IsNullOrEmpty(dept)) { dept = System.Web.HttpContext.Current.Session["UserDepartment"].ToString(); model.DeptFilter = dept; } repoResponse = nominationRepo.GetReportDetails(_loggedInUserID, dept, fromDate, toDate); if (repoResponse.success) { partModel = repoResponse.Data; model.participatedCount = partModel; } model.From_Date = DateTime.Now.ToString("MMMM yyyy"); model.To_Date = DateTime.Now.ToString("MMMM yyyy"); return(View(model)); }
public ActionResult GeneratePDF(string ID) { //ID = "1"; _nominationRepo = new NominationRepo(); using (MemoryStream stream = new System.IO.MemoryStream()) { string subPath = "~/HTMLFiles/"; string path = Server.MapPath(subPath) + "NominationHTMLFormat.html"; string PDFBody = System.IO.File.ReadAllText(path); //string PDFBody = System.IO.File.ReadAllText(@"D:\Personal Work\Project GitHub\StarOfTheMonth\StarOfTheMonth\HTMLFiles\NominationHTMLFormat.html"); string data = _nominationRepo.GetNomineeContentsForPDFExport(PDFBody, ID); StringReader sr = new StringReader(data); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); PdfWriter writer = PdfWriter.GetInstance(pdfDoc, stream); pdfDoc.Open(); XMLWorkerHelper.GetInstance().ParseXHtml(writer, pdfDoc, sr); pdfDoc.Close(); return(File(stream.ToArray(), "application/pdf", "NominationForm_" + ID + ".pdf")); } //// instantiate the html to pdf converter //HtmlToPdf converter = new HtmlToPdf(); //// convert the url to pdf //PdfDocument doc = converter.ConvertUrl("http://*****:*****@"D:\Personal Work\Documents\PDF Export\file.pdf"); //// close pdf document //doc.Close(); ////References : http://www.intstrings.com/ramivemula/articles/export-asp-net-mvc-view-to-pdf-in-3-quick-steps/ ////return new Rotativa.ActionAsPdf("/Nomination/Nomination?id=1"); //return new Rotativa.ActionAsPdf("Nom?id=1"); ////return new Rotativa.ActionAsPdf("http://localhost:50967/Nomination/Nomination?id=1"); ////// instantiate the html to pdf converter ////HtmlToPdf converter = new HtmlToPdf(); ////// convert the url to pdf ////PdfDocument doc = converter.ConvertUrl(url); ////// save pdf document ////doc.Save(file); ////// close pdf document ////doc.Close(); ////// instantiate the html to pdf converter ////HtmlToPdf converter = new HtmlToPdf(); ////// convert the url to pdf ////PdfDocument doc = converter.ConvertUrl(url); ////// save pdf document ////doc.Save(file); ////// close pdf document ////doc.Close(); }
// GET: Nomination //[HttpGet] public ActionResult Nomination(long ID = 0) { _repoResponse = new RepositoryResponse(); NominationModel model = new NominationModel(); if (ID > 0) { string subPath = "~/Uploads/nominationID/"; string fpath = string.Empty; bool exists = System.IO.Directory.Exists(subPath); if (exists) { System.IO.Directory.CreateDirectory(Server.MapPath(subPath)); } fpath = Server.MapPath(subPath); _nominationRepo = new NominationRepo(); string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString(); _repoResponse = _nominationRepo.GetNominationByID(_loggedInUserID, ID, fpath); if (_repoResponse.success) { model = _repoResponse.Data; List <SelectListItem> lstItem = new List <SelectListItem>(); SelectListItem s1 = new SelectListItem(); s1.Text = "Cost(in Lakhs)"; s1.Value = "1"; lstItem.Add(s1); SelectListItem s2 = new SelectListItem(); s2.Text = "Time(in hours)"; s2.Value = "2"; lstItem.Add(s2); SelectListItem s3 = new SelectListItem(); s3.Text = "Paper(in Sheets)"; s3.Value = "3"; lstItem.Add(s3); model.Savings = lstItem; return(View(model)); } } else { string _loggedInUserID = System.Web.HttpContext.Current.Session["UserID"].ToString(); if (!string.IsNullOrEmpty(_loggedInUserID)) { _nominationRepo = new NominationRepo(); _repoResponse = new RepositoryResponse(); _repoResponse = _nominationRepo.NominationRestrictionCount(_loggedInUserID); if (!_repoResponse.success) { model.NominationMessage = _repoResponse.message; } } model.Name = System.Web.HttpContext.Current.Session["UserFullName"].ToString(); model.EmployeeNumber = System.Web.HttpContext.Current.Session["UserID"].ToString(); model.Department = System.Web.HttpContext.Current.Session["UserDepartment"].ToString(); List <SelectListItem> lstItem = new List <SelectListItem>(); SelectListItem s1 = new SelectListItem(); s1.Text = "Cost(in Lakhs)"; s1.Value = "1"; lstItem.Add(s1); SelectListItem s2 = new SelectListItem(); s2.Text = "Time(in hours)"; s2.Value = "2"; lstItem.Add(s2); SelectListItem s3 = new SelectListItem(); s3.Text = "Paper(in Sheets)"; s3.Value = "3"; lstItem.Add(s3); model.Savings = lstItem; return(View(model)); } return(Json(new { success = _repoResponse.success.ToString(), message = _repoResponse.message })); }