public async Task <int> InsertEmployeeAttachmentFileAsync(EmployeeAttachmentFileDto dto)
        {
            var sql = " DECLARE @ID int;" +
                      " INSERT INTO [dbo].[AttachmentFile] " +
                      " ([EmpId] " +
                      " ,[AttachmentFileName] " +
                      " ,[CreatedId] " +
                      " ,[CreatedDate]) " +
                      " VALUES " +
                      " (@EmpId " +
                      " ,@AttachmentFileName " +
                      " ,@CreatedId " +
                      " ,GETDATE() )" +
                      " SET @ID = SCOPE_IDENTITY(); " +
                      " SELECT @ID";

            var id = await Connection.QuerySingleAsync <int>(sql, new
            {
                EmpId = dto.EmpId,
                AttachmentFileName = dto.AttachmentFileName,
                CreatedId          = dto.CreatedId,
            }, Transaction);

            return(id);
        }
        public async Task <IActionResult> Post([FromBody] EmployeeAttachmentFileDto dto)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new { message = "Not a valid model" + ModelState.ToString() }));
            }
            try
            {
                _UnitOfWork.Transaction = _UnitOfWork.Begin();
                var duplicate = await _UnitOfWork.AttachmentFileRepository.GetEmployeeAttachmentFileNameAsync(dto);

                if (duplicate.Any())
                {
                    return(BadRequest(new { message = "Duplicated file" }));
                }
                var id = await _UnitOfWork.AttachmentFileRepository.InsertEmployeeAttachmentFileAsync(dto);

                _UnitOfWork.Commit();

                return(Ok(id));
            }
            catch (Exception ex)
            {
                _UnitOfWork.Dispose();
                return(BadRequest(new { message = ex.Message }));
            }
            finally
            {
                _UnitOfWork.Dispose();
            }
        }
        public async Task <IEnumerable <EmployeeAttachmentFileDto> > GetEmployeeAttachmentFileNameAsync(EmployeeAttachmentFileDto dto)
        {
            var sql = " SELECT  Id , ProjectId, AttachmentFileName , CreatedId , CreatedDate  " +
                      " FROM AttachmentFile  " +
                      " where AttachmentFileName = @fileName" +
                      " and EmpId = @EmpId" +
                      "  order by CreatedDate desc ";

            return(await SqlMapper.QueryAsync <EmployeeAttachmentFileDto>(Connection, sql, new { fileName = dto.AttachmentFileName, EmpId = dto.EmpId }, transaction : Transaction));
        }