예제 #1
0
 public static SummarySuggestionDto Create(SummarySuggestion summarySuggestion)
 {
     return(new SummarySuggestionDto(
                summarySuggestion.Id,
                SummaryDto.Create(summarySuggestion.Summary),
                summarySuggestion.Status));
 }
예제 #2
0
        public SummarySuggestion Update(SummarySuggestion summarySuggestion)
        {
            SummarySuggestion oldSuggestion = _summarySuggestions.Find(s => s.Id == summarySuggestion.Id);

            _summarySuggestions.Remove(oldSuggestion);
            _summarySuggestions.Add(summarySuggestion.Copy());
            return(summarySuggestion);
        }
예제 #3
0
 public static DbSummarySuggestion FromModel(SummarySuggestion summarySuggestion)
 {
     return(new DbSummarySuggestion()
     {
         Id = summarySuggestion.Id,
         SummaryId = summarySuggestion.Summary.Id,
         VacancyId = summarySuggestion.Vacancy.Id,
         Status = summarySuggestion.Status
     });
 }
예제 #4
0
        public void SkipSuggestionForUser(Int32 userId, Int32 suggestionId)
        {
            Vacancy vacancy = GetVacancyForUser(userId);

            SummarySuggestion suggestion = _summarySuggestionRepository.Get(suggestionId);

            if (suggestion.Vacancy.Id != vacancy.Id)
            {
                throw new ArgumentException(
                          $"User with id {userId} don't have access for suggestion with id {suggestion.Id}!");
            }

            suggestion.Skip();
            _summarySuggestionRepository.Update(suggestion);
        }
예제 #5
0
        public SummarySuggestion Update(SummarySuggestion summarySuggestion)
        {
            DbSummarySuggestion dbSummarySuggestion = _context.SummarySuggestions
                                                      .SingleOrDefault(s => s.Id == summarySuggestion.Id) ??
                                                      throw new ArgumentException($"No summary suggestion with id {summarySuggestion.Id}!");

            dbSummarySuggestion.Status = summarySuggestion.Status;

            dbSummarySuggestion = _context.SummarySuggestions
                                  .Update(dbSummarySuggestion)
                                  .Entity;

            try
            {
                _context.SaveChanges();
            }
            catch (DbUpdateException)
            {
                throw new ArgumentException("Unable to create summary suggestions with such data!");
            }

            return(dbSummarySuggestion.ToModel());
        }