Ejemplo n.º 1
0
        public async Task <ActionResult> Create(RecruitmentViewModel rvm /*, HttpPostedFileBase[] FILEPhoto*/)
        {
            try
            {
                RecruitmentViewModel pvm = new RecruitmentViewModel();
                int NewRecruitmentID     = 0;
                //string Name = string.Empty;
                //string strImageLink = string.Empty;
                //string ext = string.Empty;
                if (!ModelState.IsValid)
                {
                    //RecruitmentViewModel rvm = new RecruitmentViewModel();
                    rvm.VisaStatusList      = GetLookUpDropDownList("VisaStatus", null);
                    rvm.EmployementTypeList = GetLookUpDropDownList("EmployementType", null);
                    rvm.RecruiterName       = User.Identity.Name;
                    rvm.RecruiterId         = User.Identity.GetUserId();

                    return(View(rvm));
                }

                Recruitment        recruitment        = new Recruitment();
                RecruitmentService recruitmentService = new RecruitmentService();


                recruitment.Email                 = rvm.Email;
                recruitment.RecruiterId           = rvm.RecruiterId;
                recruitment.PhoneNumber           = rvm.PhoneNumber;
                recruitment.FirstName             = rvm.FirstName;
                recruitment.LastName              = rvm.LastName;
                recruitment.LookupEmployementType = rvm.LookupEmployementType;
                recruitment.AvailableDate         = rvm.AvailableDate;
                recruitment.Notes                 = rvm.Notes;
                recruitment.CurrentLocation       = rvm.CurrentLocation;
                recruitment.C2CCompanyName        = rvm.C2CCompanyName;
                recruitment.C2CContactNumber      = rvm.C2CContactNumber;
                recruitment.C2CContactPerson      = rvm.C2CContactPerson;
                recruitment.C2CEmail              = rvm.C2CEmail;

                //RecruitmentClientListViewModel rlvm = new RecruitmentClientListViewModel();
                //rlvm.JobLocation = rvm.JobLocation;
                //rlvm.JobTitle = rvm.JobTitle;
                //rlvm.CandidateStatusList = rvm.CandidateStatusList;
                //rlvm.ClientName = rvm.ClientName;
                //rlvm.Comments = rvm.Comments;
                //rlvm.LookupCandidateStatus = rvm.LookupCandidateStatus;

                recruitment.LookupVisaStatus  = rvm.LookupVisaStatus;
                recruitment.PrimarySkillSet   = rvm.PrimarySkillSet;
                recruitment.SecondarySkillSet = rvm.SecondarySkillSet;
                recruitment.IsActive          = true;
                recruitment.IsDeleted         = false;
                recruitment.CreatedUserId     = User.Identity.GetUserId();
                recruitment.CreatedDate       = DateTime.Now;
                recruitment.ModifiedDate      = DateTime.Now;
                recruitment.ModifiedUserId    = User.Identity.GetUserId();

                //Insert data for recruitment table and get newly inserted ID
                NewRecruitmentID = recruitmentService.SetRecruitment(recruitment);
                ////Upload Files
                //foreach (HttpPostedFileBase varfile in FILEPhoto)
                //{
                //    if (varfile != null && varfile.ContentLength > 0)
                //    {
                //        ext = Path.GetExtension(varfile.FileName);
                //        //Name = Guid.NewGuid() + ext;
                //        Name = varfile.FileName;
                //        strImageLink = strImageLink + Name + ",";
                //        var newFileName = Path.Combine(Server.MapPath("~" + ConfigurationManager.AppSettings["RecruitDocument"]), Name);
                //        varfile.SaveAs(newFileName);
                //    }

                //}
                ////Insert data into RecruitmentDocuments
                //foreach (HttpPostedFileBase varfile in FILEPhoto)
                //{
                //    if (varfile != null && varfile.ContentLength > 0)
                //    {
                //        RecruitmentDocument Objrd = new RecruitmentDocument()
                //        {
                //            RecruitmentId = NewRecruitmentID,
                //            FileServerPath = ConfigurationManager.AppSettings["RecruitDocument"],
                //            RecruitmentDocumentName = varfile.FileName,
                //            IsActive = true,
                //            IsDeleted = false,
                //            CreatedUserId = User.Identity.GetUserId(),
                //            CreatedDate = DateTime.Now
                //        };
                //        recruitmentService.SetRecruitmentDocument(Objrd);
                //    }
                //}



                TempData["status"] = "Consultant details successfully added. Please upload documents if any";

                return(RedirectToAction("Edit", "Recruitment", new { id = NewRecruitmentID }));
            }
            catch (Exception ex)
            {
                rvm.VisaStatusList = GetLookUpDropDownList("VisaStatusList", null);
                TempData["error"]  = "Something went wrong while adding Recruiter";
                return(View(rvm));
            }
        }