public DegreeDTO Save(DegreeForm form)
        {
            var          transaction = _humanManagerContext.Database.BeginTransaction();
            DegreeEntity entity      = null;

            try
            {
                string folderName            = SystemContant.Degrees_Uploading_Path;
                string uploadPath            = _hostingEnvironment.ContentRootPath;
                string newPath               = Path.Combine(uploadPath, folderName);
                UploadUtil.Uploader uploader = _uploadUtil.DoFileUploading(newPath, form.UploadedFile);

                DegreeEntity newEntity = _mapper.Map <DegreeEntity>(form);
                newEntity.ImageName = uploader.fileName;
                entity = _humanManagerContext.Degrees.Add(newEntity).Entity;
                _humanManagerContext.SaveChanges();
                transaction.Commit();

                DegreeDTO dto = _mapper.Map <DegreeDTO>(entity);
                return(dto);
            }
            catch
            {
                transaction.Rollback();
                return(null);
            }
        }
        public CandidateDTO Save(CandidateForm canForm)
        {
            CandidateEntity entity = null;
            NoteDTO         note   = new NoteDTO();

            note.Content = "";
            note.Id      = 0;
            canForm.Note = note;
            note         = _noteService.Save(_mapper.Map <NoteEntity>(canForm.Note));
            canForm.Note = note;
            var transaction = _humanManagerContext.Database.BeginTransaction();

            try
            {
                string folderName             = SystemContant.Candidate_Uploading_Path;
                string uploadPath             = _hostingEnvironment.ContentRootPath;
                string newPath                = Path.Combine(uploadPath, folderName);
                UploadUtil.Uploader uploader  = _uploadUtil.DoFileUploading(newPath, canForm.UploadedFile);
                CandidateEntity     newEntity = _mapper.Map <CandidateEntity>(canForm);
                newEntity.ImageName = uploader.fileName;
                entity = _humanManagerContext.Candidates.Add(newEntity).Entity;
                _humanManagerContext.SaveChanges();

                transaction.Commit();
                CandidateDTO dto = _mapper.Map <CandidateDTO>(entity);
                return(dto);
            }
            catch
            {
                transaction.Rollback();
                return(null);
            }
        }