public virtual IActionResult Index(string id) { var model = new ProgramAssessmentVM(); if (string.IsNullOrEmpty(id)) { return(View(model)); } else { //Guid i; if (IsValidGuid(id)) { var gid = ParseGuid(id); //Guid gid = new Guid(id); //var ids = Guid.TryParse(gid, out i); if (gid != null) { var getDetails = (from c in _context.ProgramAssessments where c.RowUniqueId == gid select c).ToList(); if (getDetails.Any()) { model.JobTitle = getDetails[0].JobTitle; model.CompanyInfo = getDetails[0].CompanyInfo; model.Description = getDetails[0].Description; model.CandidateProfile = getDetails[0].CandidateProfile; model.ApplicationInformation = getDetails[0].AccountInfo; //model.Id = getDetails[0].Id.ToString(); model.Identifier = getDetails[0].RowUniqueId.ToString(); ViewBag.File = "jobs.jpg"; return(View(model)); } else { ViewData["Error"] = "Your requested data not available"; return(View(model)); } } else { ViewData["Error"] = "Invalid parameter"; return(View(model)); } } else { ViewData["Error"] = "Invalid parameter"; return(View(model)); } } }
public IActionResult Create(ProgramAssessmentVM pavm) { if (ModelState.IsValid) { var pa = new ProgramAssessments(); pa.JobTitle = pavm.JobTitle; pa.CompanyInfo = pavm.CompanyInfo; pa.Description = pavm.Description; pa.CandidateProfile = pavm.CandidateProfile; pa.AccountInfo = pavm.ApplicationInformation; pa.FilePath = GetWwwRootPath(_appEnvironment); //pa.Id = pavm.Identifier != null ? GetProgramAssessment(pavm.Identifier) : pavm.Id; if (!string.IsNullOrEmpty(pavm.Identifier)) { var i = ParseGuid(pavm.Identifier.ToString()); pa.Id = GetProgramAssessment(i); pa.RowUniqueId = ParseGuid(pavm.Identifier); // _context.Entry(pa).State = EntityState.Modified; _context.Update(pa); } else { pa.RowUniqueId = Guid.NewGuid(); _context.ProgramAssessments.Add(pa); } try { _context.SaveChanges(); } catch (Exception ex) { ViewData["Error"] = "Unexpected error. Please try again"; return(View("Index", pavm)); } pavm.Identifier = pa.RowUniqueId.ToString(); ViewData["Success"] = "Your data saved successfully"; ViewBag.File = "jobs.jpg"; return(View("Index", pavm)); } else { ViewData["Error"] = "Please fill all the fields"; return(View("Index", pavm)); } }
protected IActionResult GetProgramAssessment(ProgramAssessmentVM pavm) { ViewData["Success"] = "Your data saved successfully"; ViewBag.File = "jobs.jpg"; return(View("Index", pavm)); }