Beispiel #1
0
        public void CreateCareer_TryToCreateCareer_ShouldRepositoryCreateOnce()
        {
            var Career = new CareerDTO {
                Id = It.IsAny <int>()
            };

            uow.Setup(x => x.Rubrics.Get(It.IsAny <int>())).Returns(new Rubric()
            {
            });

            // act
            carService.CreateCareer(Career);

            //assert
            careerRepository.Verify(x => x.Create(It.IsAny <Career>()));
        }
Beispiel #2
0
        public IActionResult Create(CareerVM model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var allResume = _career.GetAllResumes().ToList();
                    if (model.Resume != null)
                    {
                        ViewBag.ErrorFileLength = "File is to large";
                        foreach (var resume in allResume)
                        {
                            if (model.Resume.FileName == resume)
                            {
                                ViewBag.errorResumeMsg = "Can not upload same resume!";
                                return(View(model));
                            }
                        }
                        string uploadFolder   = Path.Combine(_env.WebRootPath, "data/resumes");
                        string uniqueFilename = model.Resume.FileName;
                        string filePath       = Path.Combine(uploadFolder, uniqueFilename);
                        string extension      = Path.GetExtension(filePath);

                        if (!ServiceHelper.IsItDocument(model.Resume))
                        {
                            ViewBag.errorUploadMsg = "Only Microsoft word and pdf files allowed.";
                        }
                        else
                        {
                            model.Resume.CopyTo(new FileStream(filePath, FileMode.Create));
                            _career.CreateCareer(model);
                            _toastNotification.AddSuccessToastMessage("the application has been successfully submitted. " +
                                                                      "Thank you and after reviewing your application, we will send you an answer.");
                            return(RedirectToAction("index", "home"));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error($"{ex.Message}");
            }
            return(View(model));
        }
Beispiel #3
0
        public IHttpActionResult Add(CareerViewModel careerView)
        {
            CareerDTO careerDTO = Mapper.Map <CareerViewModel, CareerDTO>(careerView);

            careerDTO.UserId = userService.GetUsers().Where(x => x.UserName == User.Identity.Name).FirstOrDefault().Id;

            try
            {
                careerService.CreateCareer(careerDTO);
            }
            catch (ArgumentNullException)
            {
                return(BadRequest());
            }
            catch (ArgumentOutOfRangeException ex)
            {
                return(BadRequest(ex.ParamName));
            }

            return(Ok());
        }