Exemplo n.º 1
0
 public OfferViewModel(OfferModel offer, string idRecruiter, DateTime modificationDate)
 {
     Offer = offer;
     IdRecruiter = idRecruiter;
     ModificationDate = modificationDate.ToLocalTime();
     TopSkills = CalculateTopSkills(offer.Skills);
 }
Exemplo n.º 2
0
 public async Task<ActionResult> Create(OfferModel model)
 {
     if (ValidateForm(model))
     {
         var userCreatingOfferId = _authenticationService.GetUserIdFromRequest(Request);
         await _applicationService.CreateJobOfferAsync(model, userCreatingOfferId);
         return RedirectToAction("OffersList", "Offer");
     }       
     return View(model);
 }
Exemplo n.º 3
0
 public async Task<ActionResult> Edit(OfferModel model)
 {
     var currentUserId = _authenticationService.GetUserIdFromRequest(Request);
     if (ValidateForm(model))
     {
         await _applicationService.UpdateJobOfferAsync(model, model.Id);
         return RedirectToAction("OffersList", "Offer");
     }
     var offerViewModel = _applicationService.GetOfferViewModelAsync(model, currentUserId);
     return View(offerViewModel);
 }
Exemplo n.º 4
0
 private bool ValidateForm(OfferModel model)
 {
     if(ModelState.IsValid)
     {
         if (model.Skills.Count < 1)
         {
             ModelState.AddModelError("notEnoughSkills", "Choose one or more skills");
         }
         if (_applicationService.AreSkillsDuplicated(model.Skills))
         {
             ModelState.AddModelError("duplicateSkills", "You can't have repeated skills");
         }
     }            
     return ModelState.IsValid;
 }
Exemplo n.º 5
0
 public OfferViewModel MapToOfferViewModel(OfferModel offerModel, string recruiterId, DateTime modificationDate)
 {
     return new OfferViewModel(offerModel, recruiterId, modificationDate);
 }
Exemplo n.º 6
0
 public OfferModel MapToOfferModel(JobOffer offer)
 {
     var skills = MapSkillsToSkillModels(offer.Skills);
     var offerModel = new OfferModel(offer.Id, offer.Name, offer.Salary, offer.Description, skills);
     return offerModel;
 }
Exemplo n.º 7
0
 public JobOffer MapToJobOffer(OfferModel model, string id)
 {
     var skills = MapSkillModelsToSkills(model.Skills);
     var offer = new JobOffer(model.Name, model.Salary, id, model.Description, skills);
     return offer;
 }
Exemplo n.º 8
0
 public async Task CreateJobOfferAsync(OfferModel model, string offerId)
 {
     var offer = _mappingService.MapToJobOffer(model, offerId);
     offer.ModificationDate = DateTime.UtcNow;
     await _dbService.InsertJobOfferAsync(offer);
 }
Exemplo n.º 9
0
 public async Task<OfferViewModel> GetOfferViewModelAsync(OfferModel offerModel, string recruiterId)
 {
     var offer = await _dbService.GetJobOfferByIdAsync(offerModel.Id);
     var offerViewModel = _mappingService.MapToOfferViewModel(offerModel, recruiterId, offer.ModificationDate);
     return offerViewModel;
 }
Exemplo n.º 10
0
 public async Task UpdateJobOfferAsync(OfferModel model, string idOffer)
 {
     var offer = _mappingService.MapToJobOffer(model, idOffer);
     offer.ModificationDate = DateTime.UtcNow;
     await _dbService.UpdateJobOfferAsync(offer, idOffer);
 }
Exemplo n.º 11
0
 public OfferViewModel()
 {
     Offer = new OfferModel();
     TopSkills = new List<SkillModel>();
 }