コード例 #1
0
        public ActionResult Update(CandidateDesignation candidateDesignation)
        {
            ApiResult <CandidateDesignation> apiResult;

            if (ModelState.IsValid)
            {
                if (candidateDesignation.Id > 0)
                {
                    apiResult = TryExecute(() =>
                    {
                        _candidateDesignationRepository.Update(candidateDesignation);
                        _unitOfWork.Commit();
                        return(candidateDesignation);
                    }, "Candidate Designation updated sucessfully");
                }
                else
                {
                    apiResult = TryExecute(() =>
                    {
                        _candidateDesignationRepository.Create(candidateDesignation);
                        _unitOfWork.Commit();
                        return(candidateDesignation);
                    }, "Candidate Designation created sucessfully");
                }
            }
            else
            {
                apiResult = ApiResultFromModelErrors <CandidateDesignation>();
            }

            return(Json(apiResult, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        public ActionResult Create(CandidateDesignation candidateDesignation)
        {
            if (ModelState.IsValid)
            {
                _candidateDesignationRepository.Create(candidateDesignation);
                _unitOfWork.Commit();

                return(RedirectToAction("Index"));
            }

            return(View(candidateDesignation));
        }