public void CreatePIFormLink(NewCandidateLinkRequest model)
 {
     using (var conn = SqlConnectionFactory.CreateConnection())
     {
         var sql = "INSERT INTO CandidateAdmin ([CandidateName], [CandidateEmail], [UniqueKey], [CreatedOn], [ExpiryDate], [IsLocked], [IsFinalized])"
                   + " VALUES (@Name, @EmailAddress, @UniqueId, GETDATE(), CONVERT(DATE, (DATEADD(DAY, 14, GETDATE()))), 0, 0) ";
         conn.Execute(sql, new { model.Name, model.EmailAddress, model.UniqueId });
     }
 }
        public ActionResult GenerateLink(NewCandidateLinkRequest model)
        {
            ModelState.Clear();
            ViewBag.Message  = CandidateService.GetCandidatePIFormUrl(ref model);
            model.PIFormLink = string.Format("{0}://{1}{2}{3}{4}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~"),
                                             PIFormLink, model.UniqueId);

            return(View("Create", model));
        }
Example #3
0
        //private void InsertMonthlyEmoluments(CandidateDisplayEntity candidateDisplayEntity, int candidateId)
        //{
        //    CandidateRepository.InsertEmoluments(ConvertToEmolumentsEntity(candidateDisplayEntity, candidateId));
        //}

        //private CandidateEmoluments ConvertToEmolumentsEntity(CandidateDisplayEntity candidateDisplayEntity, int candidateId)
        //{
        //    return new CandidateEmoluments()
        //    {
        //        CandidateId = candidateId,
        //        Basic = candidateDisplayEntity.MonthlyEmoluments.Basic,
        //        HRA = candidateDisplayEntity.MonthlyEmoluments.HRA,
        //        Allowances = candidateDisplayEntity.MonthlyEmoluments.Allowances,
        //        FixedOthers = candidateDisplayEntity.MonthlyEmoluments.FixedOthers,
        //        Medical = candidateDisplayEntity.MonthlyEmoluments.Medical,
        //        Food = candidateDisplayEntity.MonthlyEmoluments.Food,
        //        LTA = candidateDisplayEntity.MonthlyEmoluments.LTA,
        //        VariableOthers = candidateDisplayEntity.MonthlyEmoluments.VariableOthers,
        //        PF = candidateDisplayEntity.MonthlyEmoluments.PF,
        //        MonthlyGross = candidateDisplayEntity.MonthlyEmoluments.MonthlyGross,
        //        AnnualGross = candidateDisplayEntity.MonthlyEmoluments.AnnualGross
        //    };
        //}

        public string GetCandidatePIFormUrl(ref NewCandidateLinkRequest model)
        {
            NewCandidateLinkRequest datamodel = CandidateRepository.CheckPIFormLinkExists(model.EmailAddress);

            if (datamodel != null && !string.IsNullOrWhiteSpace(datamodel.UniqueId))
            {
                //Existing
                model.State      = 1;
                model.UniqueId   = datamodel.UniqueId;
                model.ExpiryDate = datamodel.ExpiryDate;
            }
            else
            {
                //Create new
                model.State    = 2;
                model.UniqueId = Guid.NewGuid().ToString().ToUpper();
                CandidateRepository.CreatePIFormLink(model);
            }

            string message = string.Empty;

            switch (model.State)
            {
            case 0:
                message = "Error creating the PI Form Link. Please get in touch with Admin.";
                break;

            case 1:
                message = "Existing active PI Link is available and will expire by " + model.ExpiryDate.ToShortDateString();
                break;

            case 2:
                message = "Success! The above PI Link will be active till " + model.ExpiryDate.ToShortDateString();
                break;

            default:
                message = "Error creating the PI Form Link. Please get in touch with Admin.";
                break;
            }
            return(message);
        }