public bool CreateRecruitmentInfo(RecruitmentInformationDto requestModel)
        {
            RecruitmentInformation newModel = _modelFactory.Map(requestModel);

            newModel.Owner = _context.Users.SingleOrDefault(x => x.Id == requestModel.OwnerId);

            _context.RecruitmentInformations.Add(newModel);
            return(_context.SaveChanges() > 0);
        }
 public RecruitmentInformation(RecruitmentInformationDto model)
 {
     CompanyName        = model.CompanyName;
     City               = model.City;
     WorkPlace          = model.WorkPlace;
     DateOfCompanyReply = model.DateOfCompanyReply;
     CompanyReply       = model.CompanyReply;
     Notes              = model.Notes;
     LinkToApplication  = model.LinkToApplication;
     IsActive           = true;
     OwnerId            = model.OwnerId;
     ApplicationDate    = model.ApplicationDate;
 }
        public bool UpdateRecruitmentInfo(int id, RecruitmentInformationDto requestModel)
        {
            RecruitmentInformation originalModel =
                _context.RecruitmentInformations.FirstOrDefault(model => model.Id.Equals(id));
            RecruitmentInformation parsedModel = _modelFactory.Map(requestModel);

            if (originalModel is null)
            {
                throw new Exception("Model not found");
            }

            parsedModel.Id = originalModel.Id;

            _context.Entry(originalModel).CurrentValues.SetValues(parsedModel);
            return(_context.SaveChanges() > 0);
        }
 public IActionResult Post([FromBody] RecruitmentInformationDto requestModel)
 {
     requestModel.OwnerId = int.Parse(_httpContextAccessor.HttpContext.User.Identity.Name);
     _ = _recruitmentService.CreateRecruitmentInfo(requestModel);
     return(CreatedAtRoute("GetRecruitmentInfoById", new { id = requestModel.Id }, requestModel));
 }
 public IActionResult Put(int recruitmentId, RecruitmentInformationDto requestModel)
 {
     _ = _recruitmentService.UpdateRecruitmentInfo(recruitmentId, requestModel);
     return(StatusCode(200, requestModel));
 }