コード例 #1
0
        public void CreateOrUpdate(CertificateAddModel addModel)
        {
            var resume = _managerRepository.Get(addModel.ResumeManagerId.Value).Resume;

            foreach (var certificate in addModel.Certificates)
            {
                certificate.ResumeId = resume.Id;
                if (!this.UpdateCertificate(certificate))
                {
                    this.CreateCertificate(certificate);
                }
            }
        }
コード例 #2
0
        public CertificateAddModel Get(int managerId)
        {
            var resume = _managerRepository.Get(managerId).Resume;

            if (resume == null || resume.CertificatesAndTrainings.Count == 0)
            {
                return(null);
            }

            CertificateAddModel addModel = new CertificateAddModel();

            addModel.ResumeManagerId = managerId;
            foreach (var certificate in resume.CertificatesAndTrainings)
            {
                addModel.Certificates.Add(certificate.ToModel());
            }

            return(addModel);
        }
コード例 #3
0
        public ActionResult Certificates(int managerId, CertificateAddModel addModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(addModel));
            }
            int userId = User.Identity.GetUserId <int>();

            // проверяем, владелец ли резюме шлет запрос на его изменение
            if (!_managerService.IsOwnedBy(userId, managerId))
            {
                return(new HttpUnauthorizedResult());
            }

            addModel.ResumeManagerId = managerId;
            _certificateService.CreateOrUpdate(addModel);

            return(RedirectToAction(string.Format("Certificates/{0}", managerId)));
        }