public async Task <IHttpActionResult> Save(ProfessionDetailsDTO model)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest("Invalid Model"));
     }
     return(Ok(await _professionService.AddOrUpdateProfessionAsync(model)));
 }
        public async Task <int> AddOrUpdateProfessionAsync(ProfessionDetailsDTO dto)
        {
            var profession     = Mapper.Map <ProfessionDetailsDTO, Profession>(dto);
            var professionInDb = await _professionRepository.CollectionWithTracking.Include(z => z.ProfessionCriterias).FirstOrDefaultAsync(f => f.Id == profession.Id);

            if (professionInDb == null)
            {
                _professionRepository.Insert(profession);
            }
            else
            {
                Mapper.Map(profession, professionInDb);
                _professionCriteriaRepository.Delete(professionInDb.ProfessionCriterias.ToArray());
                professionInDb.ProfessionCriterias.AddRange(profession.ProfessionCriterias);
                _professionRepository.Update(professionInDb);
            }
            await _unitOfWork.SaveChangesAsync();

            return(profession.Id);
        }