public ActionResult UpdateCandidate(CandidateEdit candidate)
 {
     if (UserRoles.UserCanEdit() == true)
     {
         candidate.LoginUser = UserRoles.UserId();
         candidate.CandidateAllcaotedResouces.FK_CandidateId = candidate.ID;
         bool isupdated = CandidateService.EditCandidate(candidate);
         if (isupdated)
         {
             return(new JsonResult {
                 Data = "The update has been successful.", JsonRequestBehavior = JsonRequestBehavior.AllowGet
             });
             //  var redirectUrl = new UrlHelper(Request.RequestContext).Action("Index", "Candidates");
             //  return Json(new { Url = redirectUrl });
         }
         else
         {
             return(new JsonResult {
                 Data = "The update is not successful.", JsonRequestBehavior = JsonRequestBehavior.AllowGet
             });
         }
     }
     else
     {
         return(RedirectToAction("Index", "Candidates"));
     }
 }
 public static bool EditCandidate(CandidateEdit CandidateModel)
 {
     using (HttpClient client = new HttpClient())
     {
         client.BaseAddress = new Uri(TimeSheetAPIURl);
         HttpResponseMessage response = client.PostAsJsonAsync(string.Format("Resource/HRMSResourceEdit"), CandidateModel).Result;
         if (response.IsSuccessStatusCode)
         {
             HttpContext.Current.Session["SuccessMessage"] = "Changes Updated Successfully !";
             return(true);
         }
         else
         {
             HttpContext.Current.Session["ErrorMessage"] = "Unable To Update The Changes Please validate !";
         }
     }
     return(false);
 }
        public ActionResult UploadDocument()
        {
            var data       = Request.Form["CandidateId"];
            var FolderPath = System.Configuration.ConfigurationManager.AppSettings["FileUploadPath"];

            if (FolderPath == null || FolderPath == "")
            {
                FolderPath = @"C:\VerserHRMS\Files\";
            }
            var           fileType     = Request.Form["FileUpload"];
            CandidateEdit theCandidate = new CandidateEdit();

            for (int i = 0; i < Request.Files.Count; i++)
            {
                HttpPostedFileBase file = Request.Files[i]; //Uploaded file
                                                            //Use the following properties to get file's name, size and MIMEType
                int              fileSize    = file.ContentLength;
                string           fileName    = file.FileName;
                string           mimeType    = file.ContentType;
                System.IO.Stream fileContent = file.InputStream;
                //To save file, use SaveAs method


                theCandidate.ID = int.Parse(data);
                if (fileType == "CVUpload")
                {
                    string path = FolderPath + "\\" + System.Configuration.ConfigurationManager.AppSettings["Resume"];
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    theCandidate.FilePath = fileName;
                    file.SaveAs(Path.Combine(path, fileName)); //File will be saved in application root
                }
                else if (fileType == "CertificateUpload")
                {
                    string path = FolderPath + "\\" + System.Configuration.ConfigurationManager.AppSettings["Certificates"];
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    file.SaveAs(Path.Combine(path, fileName)); //File will be saved in application root
                    theCandidate.certificate1 = fileName;
                }
                else if (fileType == "DL")
                {
                    string path = FolderPath + "\\" + System.Configuration.ConfigurationManager.AppSettings["DL"];
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    file.SaveAs(Path.Combine(path, fileName)); //File will be saved in application root
                    theCandidate.DriverLicense = fileName;
                }
                else if (fileType == "PC")
                {
                    string path = FolderPath + "\\" + System.Configuration.ConfigurationManager.AppSettings["PC"];
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    file.SaveAs(Path.Combine(path, fileName)); //File will be saved in application root
                    theCandidate.PoliceCheckReport = fileName;
                }
                else if (fileType == "Visa")
                {
                    string path = FolderPath + "\\" + System.Configuration.ConfigurationManager.AppSettings["Visa"];
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    file.SaveAs(Path.Combine(path, fileName)); //File will be saved in application root
                    theCandidate.Visa = fileName;
                }
                else if (fileType == "Super")
                {
                    string path = FolderPath + "\\" + System.Configuration.ConfigurationManager.AppSettings["Super"];
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    file.SaveAs(Path.Combine(path, fileName)); //File will be saved in application root
                    theCandidate.SuperChoice = fileName;
                }
                else if (fileType == "TNF")
                {
                    string path = FolderPath + "\\" + System.Configuration.ConfigurationManager.AppSettings["TNF"];
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    file.SaveAs(Path.Combine(path, fileName)); //File will be saved in application root
                    theCandidate.TFNDeclaration = fileName;
                }
                else if (fileType == "Bank")
                {
                    string path = FolderPath + "\\" + System.Configuration.ConfigurationManager.AppSettings["Bank"];
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    file.SaveAs(Path.Combine(path, fileName)); //File will be saved in application root
                    theCandidate.BankDetails = fileName;
                }
                else if (fileType == "Code")
                {
                    string path = FolderPath + "\\" + System.Configuration.ConfigurationManager.AppSettings["Code"];
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    file.SaveAs(Path.Combine(path, fileName)); //File will be saved in application root
                    theCandidate.CodeOFConduct = fileName;
                }
                else if (fileType == "WHS")
                {
                    string path = FolderPath + "\\" + System.Configuration.ConfigurationManager.AppSettings["WHS"];
                    if (!Directory.Exists(path))
                    {
                        Directory.CreateDirectory(path);
                    }
                    file.SaveAs(Path.Combine(path, fileName)); //File will be saved in application root
                    theCandidate.WHS = fileName;
                }
                //string _path = Path.Combine(Server.MapPath("~/UploadedFiles"), _filename);
            }
            CandidateService.EditCandidate(theCandidate);
            return(RedirectToAction("Index"));

            //theCandidate.ID = candidateId;
        }