コード例 #1
0
        public async Task <bool> UpdateCandidate(CreateCandidate candidate)
        {
            bool result = false;

            try
            {
                var details = await _context.Candidate.FindAsync(candidate.CandidateId);

                if (details != null && candidate != null)
                {
                    details.FirstName      = candidate.FirstName;
                    details.LastName       = candidate.LastName;
                    details.Nationality    = candidate.Nationality;
                    details.Idnumber       = candidate.Idnumber;
                    details.Dob            = candidate.Dob;
                    details.Race           = candidate.Race;
                    details.Gender         = candidate.Gender;
                    details.CurrentSalary  = candidate.CurrentSalary;
                    details.CellPhone      = candidate.CellPhone;
                    details.AlterCellPhone = candidate.AlterCellPhone;
                    details.WorkNumber     = candidate.WorkNumber;
                    details.Email          = candidate.Email;

                    _context.Candidate.Update(details);
                    await _context.SaveChangesAsync();

                    result = true;
                }
            }
            catch (Exception e)
            {
            }
            return(result);
        }
コード例 #2
0
        public async Task <IActionResult> UpdateCandidate([FromBody] CreateCandidate candidate)
        {
            bool result = false;

            if (ModelState.IsValid)
            {
                result = await _repo.UpdateCandidate(candidate);
            }
            if (result == true)
            {
                return(Accepted());
            }
            else
            {
                return(NoContent());
            }
        }
コード例 #3
0
ファイル: AccountController.cs プロジェクト: pennsong/OB
        public ActionResult CreateCandidateSave(CreateCandidate model, string returnUrl = "CandidateIndex")
        {
            ViewBag.Path1 = "用户";
            if (ModelState.IsValid)
            {
                // 尝试注册用户
                try
                {
                    using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required))
                    {
                        // transaction
                        string tmpPassword = GenerateRandomPassword(6);
                        WebSecurity.CreateUserAndAccount(model.UserName, tmpPassword, new { Mail = model.Mail, IsDeleted = false });

                        Roles.AddUsersToRoles(new[] { model.UserName }, new[] { "Candidate" });

                        var user     = db.User.Where(a => a.Name == model.UserName).Single();
                        var employee = new Employee {
                            UserId = user.Id, User = user, EmployeeStatus = EmployeeStatus.新增未通知, ChineseName = model.ChineseName, ClientId = model.ClientId
                        };
                        db.Employee.Add(employee);

                        db.PPSave();

                        Common.MailTo(model.Mail, "E-Onboarding新建用户通知", "您的用户名:" + model.UserName + ",密码:" + tmpPassword + ",登陆网址:" + "<a href='" + Url.Action("Login", "Account", null, "http") + "'>登陆E-Onboarding</a>");

                        scope.Complete();
                        // end transaction
                    }
                    Common.RMOk(this, "记录:'" + model.UserName + "'新建成功!");
                    return(Redirect(Url.Content(returnUrl)));
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("", ErrorCodeToString(e.StatusCode));
                }
            }

            // 如果我们进行到这一步时某个地方出错,则重新显示表单
            ViewBag.ReturnUrl = returnUrl;
            return(View("CreateCandidate", model));
        }
コード例 #4
0
        //first create the candidate and there after we can call the LinkCandidateToPosition Method
        public async Task <bool> CreateCandidate(CreateCandidate candidate)
        {
            bool      result  = false;
            Candidate details = null;

            try
            {
                if (candidate != null)
                {
                    details = new Candidate()
                    {
                        ConsultantId   = candidate.ConsultantId,
                        DecisionStatus = candidate.DecisionStatus,
                        FirstName      = candidate.FirstName,
                        LastName       = candidate.LastName,
                        Nationality    = candidate.Nationality,
                        Idnumber       = candidate.Idnumber,
                        Dob            = candidate.Dob,
                        Race           = candidate.Race,
                        Gender         = candidate.Gender,
                        CurrentSalary  = candidate.CurrentSalary,
                        CellPhone      = candidate.CellPhone,
                        AlterCellPhone = candidate.AlterCellPhone,
                        WorkNumber     = candidate.WorkNumber,
                        Email          = candidate.Email,
                        FeedBack       = candidate.FeedBack
                    };
                    _context.Candidate.Add(details);
                    await _context.SaveChangesAsync();

                    result = true;
                }
            }
            catch (Exception ex)
            {
            }
            return(result);
        }